|
yingkou wrote:
Power Is Push Down
keybd_event(255,0,0,0);
keybd_event(255,0,KEYEVENTF_KEYUP,0);
Failure
What on earth made you decide that 255 = the power button ? The power button does not have a value, any more than your reset key does. They are hardwired to the motherboard, not to your keyboard.
yingkou wrote:
what should I do?
Use ExitWindowsEx
yingkou wrote:
I don't want to use ExitWindowsEx
Get over it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
thanks for your answer.you mean I can not control the power button in my program just like by keybd_event. If I just want to control it,what should I do? I don't want to use ExitWindowEx,because I have some special reason.
|
|
|
|
|
yingkou wrote:
If I just want to control it,what should I do?
Use ExitWindowsEx.
yingkou wrote:
I don't want to use ExitWindowEx,because I have some special reason.
I'm sorry, but that's too bad. That's the API that does what you want, not a thing you can do about it.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Can anyone tell me how to determine if a network adapter is wireless or not? It is obviously possible, since MS makes that distinction in their GUI and in ipconfig, but I can't find anywhere in the network structures to make that determiniation.
Thanks for any help.
|
|
|
|
|
Has anyone else found that adding a String to a GraphicsPath, GraphicsPath.AddString, produces a smaller font size than using Graphics.AddString -
there is nothing in my code which is adding any global transformations to the path.
In the microsoft documentation it shows that the font size for Using GraphicsPath.AddString is in World Units ??? anybody have a suggestion to make the font size correct ?
<br />
<br />
void DrawTextPathRect(Graphics *g,float x, float y,float width, float height,LPCSTR str, LPCSTR strFont, float size, int align, int style,COLORREF cr, int alpha)<br />
{<br />
CString s(_T(str));<br />
CString sFont(_T(strFont));<br />
Font font(sFont.AllocSysString(), size);<br />
<br />
FontFamily ff<br />
<br />
font.GetFamily(&ff);<br />
<br />
StringFormat sf;<br />
sf.SetAlignment((StringAlignment) (align&3));<br />
RectF p(x, y,width,height);<br />
<br />
SolidBrush crBrush(Color(alpha, GetRValue(cr), GetGValue(cr), GetBValue(cr)));<br />
<br />
g->SetCompositingMode( CompositingModeSourceOver );<br />
g->SetSmoothingMode( SmoothingModeAntiAlias );<br />
g->SetCompositingQuality( CompositingQualityAssumeLinear );<br />
g->SetTextRenderingHint( TextRenderingHintAntiAlias );<br />
<br />
g->DrawString(<br />
s.AllocSysString(),<br />
s.GetLength(),<br />
&font,<br />
p,<br />
&sf,<br />
&crBrush);<br />
<br />
<br />
}<br />
<br />
<br />
GraphicsPath *BuildTextPathRect(float x, float y,float width, float height,LPCSTR str, LPCSTR strFont, float size, int align, int style)<br />
{<br />
CString s(_T(str));<br />
CString sFont(_T(strFont));<br />
Font font(sFont.AllocSysString(), size);<br />
<br />
FontFamily ff;<br />
font.GetFamily(&ff);<br />
<br />
StringFormat sf;
sf.SetAlignment((StringAlignment) align);<br />
RectF p(x, y,width,height);<br />
GraphicsPath *path = new GraphicsPath();<br />
<br />
REAL enSize = font.GetSize();<br />
path->AddString(s.AllocSysString(), s.GetLength(), &ff, (FontStyle) style, enSize, p, & sf);<br />
<br />
return path;<br />
<br />
}<br />
robert
|
|
|
|
|
How do I make an edit box, one that initializes with a preloaded value, come up with the value selected (highlighted) when you click on it. I can't find any difference between the edit boxes that have this characteristic and ones that don't.
|
|
|
|
|
After edit control is created you can do the following:
SetWindowText() (sends WM_SETTEXT) to set the the text in edit box.
EM_SETSEL Is used to highlight the text, I do not remmeber if the control has to be active for highlight to show up.
------------------------------------
See "Edit Control Messages" in MSDN.
If the control is in a dialog, you could do the above in the OnInitDialog().
INTP
|
|
|
|
|
Hi,
Plz gurus do help me ... im in deep....
well prb is .. i want to CEditView behaving like a command prompt;
that is;
1. i want to show a prompt at the beginning of the line.
2. i want to recieve commands written in the view.
3. i want to display the text that is generated by my program into the text and here comes the problem ...
I am unable to find a function that can help me displaying text that is generated by my program.
therefore i cant add a prompt o each line and unable to carry the caret forward to the point where the prompt ends.
conclusively i can say that i need a function that can help me writing my own strings of text into CEditView as well as moving the caret to the position where my strings end.
Plzzzzzzzzz Help me
Fuad
|
|
|
|
|
// Get access to the edit contol and use its
// methods to manuipulate test and move caret.
CEdit& ctrlEdit = editView.GetEditCtrl();
See "CEdit" and "Edit Control Messages" in MSDN.
INTP
|
|
|
|
|
I have been working with the sample on how to Create Custom Explorer bars for Internet Explorer and have successfully gotten the sample code to work. My question now is how do I get the controls that I add to the custom explorer bar to use the XP Visual Styles. I have looked at the article in MSDN but cannot make it work. Anyone know how to get XP Visual Styles to work in an Explorer Bar .dll???
The sample is the Band Objects sample in the Platform SDK:
ms-help://MS.PSDK.1033/shellcc/platform/shell/programmersguide/samples/bands
|
|
|
|
|
I was wondering if there is a way to get the height of the taskbar buttons? I tried using the Shell_TrayWnd, but it doesn't work when the taskbar is more than one line. Any ideas? Thanks!
|
|
|
|
|
If you use Spy++, you will see that the buttons are actually a SysTabControl32 with the TCS_BUTTONS style, that is a child of the Shell_TrayWnd with a Control ID of 1. So it is simply a matter of getting the HWND of the tab control, and sending an TCM_GETITEMRECT message to that window.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks for the reply. When I use Spy++, I cannot target the buttons, it says they are contained in a ToolbarWindow32 with a control ID of 0. Will this be the same for every version of Windows, or does the version change the class type? I was looking for a universal way to get the height of the taskbar buttons. Thanks.
|
|
|
|
|
Ok, it's a little bit more complicated than I originally thought, but Spy++ is still the tool to use. In the "Window" view, find and expand the "Shell_TrayWnd" class window and you will find the following (at least I find it on W98 and W2K):
+ Shell_TrayWnd
Button
+ TrayNotifyWnd
TrayClockWClass
ToolBarWindow32
+ ReBarWindow32
+ MSTaskSwWClass
SysTabControl32 <== This is the window you want
ToolBarWindow32
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I am hosting the web browser control in an mfc app, and update the user using jscript that is embedded in the page. The jscript function updates the innerHTML of a div with the status message passed to the function. However when calling this method from an mfc app the window does not update to reflect the changes unless i display a message box immediatly after my call to InvokeHelper. I tried converting so that i had multiple threads but that did not help either. Here is a code dump.
Main Thread MFC App
while(bContinue)
{
dwResult = WaitForMultipleObjects(2,hEvents,FALSE,1000);
switch(dwResult)
{
case WAIT_OBJECT_0:
ExecuteStatusFunction(g_strMsg);
break;
case WAIT_OBJECT_0 + 1:
bContinue = false;
break;
default:
break;
}
}
The Function in mfc that calls the jscript
void CSensorTestView::ExecuteStatusFunction(CString strStatus)
{
MSHTML::IHTMLDocument2Ptr spDoc(GetHtmlDocument());
if( spDoc )
{
IDispatchPtr spDisp(spDoc->GetScript());
if( spDisp )
{
OLECHAR FAR* szMember = L"DoStatus";
DISPID dispid;
HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1,
LOCALE_SYSTEM_DEFAULT, &dispid);
if( SUCCEEDED(hr) )
{
COleVariant vtResult;
static BYTE parms[] = VTS_BSTR;
COleDispatchDriver dispDriver(spDisp, FALSE);
dispDriver.InvokeHelper(dispid, DISPATCH_METHOD, VT_VARIANT,
(void*)&vtResult, parms,
strStatus);
}
}
}
}
Finally the jscript on the page
function DoStatus(msg){
document.getElementById("Status").innerHTML = "
" + msg;
}
Thanks for any help
|
|
|
|
|
Is there a way to make a file delete itself? I'm trying to find out if it's possible to make an .exe that generates a key for an app, then deletes itself on shutdown?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
|
Yes, but it requires some roundabout work. The gyst of is is that the EXE should create a batch file that tries to delete that EXE file and then itself, and then the EXE should shut down. The batch file then will be able to delete the EXE file. (Note that batch files have the unique ability to delete themselves.)
The batch file would be something along the lines of this (please excuse any syntax errors!)
rem First, delete the EXE. It will be in use unti
rem it quits, so keep trying until we succeed.
:label
DEL myfile.exe
if exist myfile.exe goto label
rem Now delete this batch file
delete %0.bat
There is an MSDN article about it - I can't recall it right now, but some searching will probably find it.
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
cool! thanks!!
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
HOW CAN I CONVERT VISUAL C++ DLL(a DLL which writed in visual C++) TO BORLAND DLL?THEN I WANT TO COMPILE IT.. PLEASE HELP ME.
gurk@n
|
|
|
|
|
If it's just standard C++, just open it with the Borland IDE and recompile.
If you're using MFC/VC++ stuff, bad luck.
|
|
|
|
|
Hi there,
I would like to build a piece of sw that creates a virtual serial port, establishes a tcp connection with a server and forwards everything that is written in the virtual serial port to the server and vice versa.
Could you please give some hints/direction on how I can do that, especially the first part?
Thank you in advance,
Nikos Nikolaou
|
|
|
|
|
Hi !
The whole solution is to design, write and register a so-called pseudo-device driver. Pseudo-devices are software components that the Windows system recognizes as devices, but which require no actual hardware to exist.
When the driver is registered and running, you can open a handle to it (CreateFile) and use ReadFile/WriteFile calls to send and receive data from it. Because a serial communications device supports overlapped I/O, you can also use event objects to request signals from the operating system when an event occurs. The easiest way to understand an event object is to think of a hardware interrupt. Waiting for an event object to signal is very much like waiting for an interrupt to trigger.
The device itself, when created, must use the Windows Sockets API to create a socket connection to the specified server. Then it can start serving the application by responding to ReadFile/WriteFile calls appropriately.
To give you a nice & handy head-start, you should see David Dunlop's article 'Introduction to Device Drivers'. The article can be found here[^]. In this article, he will help you through the process of creating and registering a pseudo-device driver that does not do anything.
For a more in-depth look, go read mjtsai's article here[^]. Follow the article through, and fill in the necessary code for your pseudo-device to
a) identify itself as a serial communications device (AddDevice-call)
b) create and connect the socket when a handle is opened (IRP_MJ_CREATE)
c) offer data transfer services to/from the socket (IRP_MJ_READ/IRP_MJ_WRITE)
d) close the socket when a handle is closed (IRP_MJ_CLOSE)
As you can see, I have named the different events to which your pseudo-device driver needs to respond. The type of device you wish to represent is called 'FILE_DEVICE_SERIAL_PORT'. This information is given during the IoCreateDevice call.
For more information on how device drivers work, I suggest buying a good book. Programming the Windows Driver Model, 2nd Edition is one of the best I can recommend. But I hope this answer will get you started.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Dear Antti,
Thank you for the info. Is there a specific socket API that can be used from driver-code, or the win2sock API is ok?
Nikos
|
|
|
|
|
The Windows Sockets 2 API is just fine. Remember to link with the libraries and triple-check your code for performance/logical errors. A driver program is running in the kernel mode, and a mistake/crash in there is fatal to the operating system. A thorough checking and simulation of all possible error states must be done.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|