|
You can use GetKeyState() in you WM_KEYDOWN processing to check the state of the shift key; or you can simply process the WM_KEYDOWN message and check the wParam parameter for VK_SHIFT and then use SendMessage() to post a new message with VK_CONTROL.
|
|
|
|
|
To make the control of IDC_RADIO1 to be enabled state,I tried SendDlgItemMessage and EnableWindow respectively.The result is the statement "EnableWindow(GetDlgItem(hDlg,IDC_RADIO1),TRUE); " succeeds, but the "
SendDlgItemMessage( hDlg, IDC_RADIO1, WM_ENABLE, (WPARAM)0L, (LPARAM)0L ); " is failing! Why???
The following is my codes:
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_INITDIALOG:<br />
return TRUE;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{ <br />
case IDOK:<br />
case IDCANCEL:<br />
EndDialog(hDlg, LOWORD(wParam));<br />
return TRUE;<br />
case IDC_BUTTON1:<br />
EnableWindow(GetDlgItem(hDlg,IDC_RADIO1),TRUE);
break;<br />
}<br />
break;<br />
}<br />
return FALSE;<br />
}
Rap off for you,for me,for our human.
|
|
|
|
|
From msdn:
The WM_ENABLE message is sent when an application changes the enabled state of a window. It is sent to the window whose enabled state is changing. This message is sent before the EnableWindow function returns, but after the enabled state (WS_DISABLED style bit) of the window has changed.
So i think WM_ENABLE is like a notification message and its handler isn't really responsible for changing the state of the control.
<font=arial>Weiye Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
|
Hello!
I need a cool Button (with MouseOver, MouseLeave and all other cool stuff), but I don't wann use any MFC Class. I need a pure SDK Cool Button.
Some ideas?
Thanxs.
|
|
|
|
|
The hover buttons here on CP would be easy enough to port.
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
All the hover buttons on CodeProject use MFC classes, and I need it pure SDK.
Thanks anyway!
|
|
|
|
|
|
What would be the "best" way to detect if a window in another process has closed (either been destroyed or received a WM_CLOSE)? I can think of 2 solutions:
- Sit in a busy loop calling
IsWindow() on the HWND of the window - Install a
WH_CBT hook and look for the HCBT_DESTROYWND notification code The first option is the easiest, but not good in terms of efficieny. The second is slightly more complex (though it's not too difficult) and would involve interprocess communication. It also has a performance hit on the system, although its processing would not be complex.
Does anyone have any other solutions?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Many more options if you control the source of the app that you need to monitor. If so, then you can broadcast a message, or set an Event, etc. in the OnDestroy of the window in question
onwards and upwards...
|
|
|
|
|
Dear All,
I am developing an dialog based application using MFC VC++ Version 6.0 for Windows 2000.
The application needs to perform certain tasks immediately before logging off /shutdown of the
system respectively.
For detecting logoff/shutdown i have handled WM_ENDSESSION event. OnEndSession call informs the
CWnd object whether the session is actually ending and this event is fired for both logoff as
well as for shutdown.
I need to detect the difference between log off event and shutdown event because I need to
perform seperate functions on logoff and shutdown.
Am I capturing the right event for handling this issue ? Also if possible please suggest any
alternate way to perform the same.
Waiting for your reply.
Regards,
Rohit
|
|
|
|
|
Hi Rohit,
When Logoff or Shutdown events occur it goes in WM_QUERYENDSESSION which in turn sends WM_ENDSESSION.
So as per your need you can distinguish using the lparam value.
If it is ENDSESSION_LOGOFF it is LogOff event and if EWX_LOGOFF it is ShutDown Event as per my observation and Testing.
Pankaj
|
|
|
|
|
Hi there
SHORT nState = GetAsyncKeyState(VK_CONTROL);
BOOL bDown = (nState & 0x8000);
what does 0x8000 mean and where can i find the infomation?
By the way,
What does (nState & 0x8000) mean?
Thanks
|
|
|
|
|
0x8000 is a hexadecimal number equal to 32768 in decimal or 1000000000000000 in binary. The value returned by GetAsyncKeyState() has bit 15 set if the key is down. However, since the value is a 16-bit SIGNED integer, a more intuitive way would be to code it like this:
SHORT nState = GetAsyncKeyState(VK_CONROL);
BOOL bDown = (nState < 0); If the state is less than 0, the key is pressed, otherwise it is released.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Intuitive??
The bitmask is better, since it doesn't rely on SHORT being typedef-ed to a signed quantity. I know it should be, but hey, I've still got code from Win3.1 that works, and one day when I have a 64 bit processor, I might port it...
Steve S
|
|
|
|
|
Ok, ok. So I find it more intuitive
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
and I for one, will defend your right to say so.
In my day, of course, one would have done a shift operation (or was that a rotate left? Ah, that's why I've stopped writing assembly code ) and tested the carry flag...
Steve S
|
|
|
|
|
Steve S wrote:
In my day, of course, one would have done a shift operation (or was that a rotate left?
Either one would work, as long as you used a 16-bit shift
BTW, what do you mean your day?? I'm 23, and still write assembler :P
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
But you are young and think it is cool to do ASM.
Back in OUR day we had to.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
you are young and think it is cool to do ASM.
Wrong. I do VC++ mainly, but I also do a lot of embedded programming - not much choice there...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ah. Embedded programming. Fitting lots of functionality into a small device (in terms of memory and sometimes processor speed).
Imagine having to do that *all* the time, when 32Kb was expensive, and mass-storage meant paper-tape...
Of course, it meant viruses were easier to spot - if your executable size went up more than a few bytes, it probably wouldn't run anymore;P
Steve S
|
|
|
|
|
the & operator compares each bit of both operands returning 1 only if both are 1.
(1 & 1) = 1
(1 & 0) = 0
(0 & 1) = 0
(0 & 0) = 0
(001101 & 101011) = 001001
this way you know weather a bit has been set or not.
|
|
|
|
|
in VC++.Net's class view, how come you can't just right click on a function to delete it?
overall, i am finding that VC++.Net is not as hot as it cracked up to be.
going back to vc++6
|
|
|
|
|
closecall wrote:
how come you can't just right click on a function to delete it?
I guess it [class view] is not really smart. I never really thought about that, but it would be nice if you could.
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
I think VC6 provieds this feature.
Toughest Steel Comes From Hottest Furnance
|
|
|
|
|
Mr.Prakash wrote:
I think VC6 provieds this feature.
It does. I wonder why MSFT removed it in VC.NET?
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|