Click here to Skip to main content
16,005,316 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Where is the problem ? please help... Pin
Member 30761228-Dec-04 19:40
Member 30761228-Dec-04 19:40 
GeneralRe: Where is the problem ? please help... Pin
pc_dev28-Dec-04 21:43
pc_dev28-Dec-04 21:43 
GeneralRe: Window Belongs to which exe file Pin
ThatsAlok28-Dec-04 21:04
ThatsAlok28-Dec-04 21:04 
GeneralRe: Window Belongs to which exe file Pin
Gary R. Wheeler29-Dec-04 1:17
Gary R. Wheeler29-Dec-04 1:17 
GeneralRe: Window Belongs to which exe file Pin
ThatsAlok29-Dec-04 1:42
ThatsAlok29-Dec-04 1:42 
GeneralRe: Window Belongs to which exe file Pin
Gary R. Wheeler29-Dec-04 2:09
Gary R. Wheeler29-Dec-04 2:09 
GeneralRe: Window Belongs to which exe file Pin
ThatsAlok29-Dec-04 2:56
ThatsAlok29-Dec-04 2:56 
GeneralRe: Window Belongs to which exe file Pin
Gary R. Wheeler29-Dec-04 4:27
Gary R. Wheeler29-Dec-04 4:27 
That's true. In Windows, a handle is a token that is used by to identify a specific object. An HWND therefore identifies a window, while an HMODULE identifies a module. When you pass an HWND when Windows expects an HMODULE, it will attempt to use a window handle to identify a module.

For example, let's suppose that handles are implemented as an index within an array. An HWND with the value of 11 would therefore specify the 11th window in the system. An HMODULE with the value of 11 would specify the 11th module in the system. The two aren't related, and you aren't going to get the results you want.

There's an even more obvious example. Suppose that handles are implemented as pointers to a structure. An HWND would therefore point to a structure that defines a window, while an HMODULE would point to a structure for a module. Passing one for the other would obviously have poor results.

While Window handles aren't implemented this way (as far as I know), you should treat them as opaque entities. This implies that, if an API function calls for a handle of a given type, you will only get the expected behavior if you pass a valid handle of that type. If you use a type cast to force the call to receive a handle of another type, then the results are unpredictable.


Software Zen: delete this;
GeneralRe: Window Belongs to which exe file Pin
ThatsAlok29-Dec-04 17:02
ThatsAlok29-Dec-04 17:02 
GeneralRe: Window Belongs to which exe file Pin
Gary R. Wheeler29-Dec-04 1:22
Gary R. Wheeler29-Dec-04 1:22 
GeneralRe: Window Belongs to which exe file Pin
Member 24341329-Dec-04 17:11
Member 24341329-Dec-04 17:11 
GeneralRe: Window Belongs to which exe file Pin
ThatsAlok29-Dec-04 19:23
ThatsAlok29-Dec-04 19:23 
GeneralAdding Lines to a Dialog box, which has so many button controls Pin
28-Dec-04 18:00
suss28-Dec-04 18:00 
GeneralRe: Adding Lines to a Dialog box, which has so many button controls Pin
pc_dev28-Dec-04 19:15
pc_dev28-Dec-04 19:15 
Generalemulator device in Window Pin
don7cry28-Dec-04 16:56
don7cry28-Dec-04 16:56 
GeneralRe: emulator device in Window Pin
pc_dev28-Dec-04 19:24
pc_dev28-Dec-04 19:24 
GeneralBoost regex (regular expressions) problem Pin
czajnick28-Dec-04 13:56
czajnick28-Dec-04 13:56 
GeneralRe: Boost regex (regular expressions) problem Pin
User 665828-Dec-04 14:33
User 665828-Dec-04 14:33 
GeneralRe: Boost regex (regular expressions) problem Pin
czajnick28-Dec-04 22:50
czajnick28-Dec-04 22:50 
GeneralRe: Boost regex (regular expressions) problem Pin
User 665829-Dec-04 1:44
User 665829-Dec-04 1:44 
GeneralRe: Boost regex (regular expressions) problem Pin
Michael Dunn29-Dec-04 6:53
sitebuilderMichael Dunn29-Dec-04 6:53 
GeneralLinking problems when using libraries! Pin
Dani10000128-Dec-04 12:59
Dani10000128-Dec-04 12:59 
GeneralRe: Linking problems when using libraries! Pin
Chris Losinger28-Dec-04 15:07
professionalChris Losinger28-Dec-04 15:07 
GeneralCapture the Fn key on a laptop Pin
sparker6228-Dec-04 9:32
sparker6228-Dec-04 9:32 
GeneralRe: Capture the Fn key on a laptop Pin
User 665828-Dec-04 9:35
User 665828-Dec-04 9:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.