Home > Software engineering >  Long into the HWND problem?
Long into the HWND problem?

Time:10-05

First post code, including the DM is a wrapper class:
//get the game window handle 
Void CtestDlg: : OnBnClickedButton1 ()
{
G_userHwnd=0;
Cstrings cGameStr="";
((CComboBox *) GetDlgItem (IDC_COMBO1)) - & gt; GetWindowTextA (cGameStr);
//MessageBox (cGameStr);
Cstrings ctStr;
CtStr=dm. EnumWindow (0, cGameStr, ", "1 + 4 + 8 + 16);

MessageBox (ctStr);
G_userHwnd=(HWND) atol (ctStr);
Dm. SetPath (" D: \ My Documents \ Visual Studio 2015 \ Projects \ test ");
HWND childWnd=NULL;
Long c_userHwnd=long (g_userHwnd);
Int the aT=330042;
//EnumChildWindows ();
ChildWnd=(HWND) FindWindowEx (g_userHwnd, NULL, NULL, _T (" Edit "));
Int a=dm. BindWindow (c_userHwnd, "dx", "normal", "Windows", 0).//under the breakpoint here
A=dm. KeyPress (65);
A=dm. UnBindWindow ();


}

Breakpoint debugging values are as follows:
- g_userHwnd zero x000708bc HWND__ *
{unused=0} int
+ childWnd 0 x00000000 & lt; NULL> HWND__ *
460988 long c_userHwnd
"460988" + ctStr ATL: : CStringT>

===========
I want to ask next
1. The first ctStr take to "notepad" window handle to 460988 into HWND data members of a g_userHwnd unused to 0 this step should be problematic
2. Receive a long c_userHwnd with strong turned long (g_userHwnd) to obtain the value of the incredibly right is 460988 this is how to understand
HWND is essentially four bytes of type int, right, strong directly into what doesn't work, should no overflow,

CodePudding user response:

The test code:
HWND a=NULL;
Long b=460988;
A=b (HWND);
Cstrings CSTR=NULL;
CSTR. The Format (" a=% d ", a);
MessageBox (CSTR);
The breakpoint debugging results:
- a zero x000708bc {unused=6563} HWND__ *
B 460988 long
+ CSTR a="460988" ATL: : CStringT>
============why a member of the unused=6563 instead of 460988

CodePudding user response:

Yes ah,,,,

CodePudding user response:

But the 1st floor of unused=0
And the test code of unused=6563
This is why, 2 piece of code is based on the 460988 number to strong go
And top 460988 turned on principle also should be 460988 just right

CodePudding user response:

and please first learn how to watch !

Computer composition principle and DOS command to assembly language, C language (not including the C + +), code written specification and data structure, compiling principle, operating system and computer network, database principle, the regular expression to other languages (including C + +), architecture...

To learn programming advice:
multi-purpose cerebellum and hand and less in the brain, eyes and mouth, will be faster to learn programming!
Eye over thousand times than hand it again!
Book is better than one thousand lines of hand knock a line!
Hand knock is better than one thousand lines of a single step line!
Single step source code is better than one thousand lines of single-step the Debug version of the corresponding assembly line!
Single step the Debug version of the corresponding assembly is better than one thousand lines of single-step Release version corresponding to the assembly line!
Will not step the Release version of the corresponding assembly? In you want to step the Release version of C/C + + code snippets in the front of the temporarily add DebugBreak (); Rebuild all, and then run in the IDE, (the average person I don't tell him! )

VC debugging when press Alt + 8, Alt + 7, Alt + 6 and Alt + 5, open the assembly window, stack window, memory window and registers the window to see each other C corresponding assembly, single step, and observe the corresponding stack memory and registers changes, this again is not what all understand,
For VC, the so-called 'when debugging is compiled to connect through the later, after press F10 or F11 key step by step, or in a row after press F9 set the breakpoint press F5 execution stops at the breakpoint,

http://edu.csdn.net/course/detail/2344 C language pointer and assembly - a memory address. The code element

CodePudding user response:

HWND is a fictional structure pointer, concrete member data is meaningless, unused didn't affect the
HWND is the system to provide an ID value, the App layer can't see the internal data

CodePudding user response:

Pointer in both 32-bit and 64 - bit mode is not the same length

CodePudding user response:

reference 5 floor zzz3265 reply:
HWND is a fictional structure pointer, concrete member data is meaningless, unused didn't affect the
HWND is the system to provide an ID value, the App layer can't see the internal data

============
You mean if I will be a value of 460988 long value assigned to the HWND, and displayed the HWND is not the value of 460988, is a normal situation?

CodePudding user response:

refer to 6th floor zgl7903 response:
pointer in both 32-bit and 64 - bit mode is not the same length

HWND is actually an int the structure of right, 460988 what 4 bytes will not overflow

CodePudding user response:

The
reference 4 floor zhao4zhong1 reply:
and please first learn how to watch !

Computer composition principle and DOS command to assembly language, C language (not including the C + +), code written specification and data structure, compiling principle, operating system and computer network, database principle, the regular expression to other languages (including C + +), architecture...

To learn programming advice:
multi-purpose cerebellum and hand and less in the brain, eyes and mouth, will be faster to learn programming!
Eye over thousand times than hand it again!
Book is better than one thousand lines of hand knock a line!
Hand knock is better than one thousand lines of a single step line!
Single step source code is better than one thousand lines of single-step the Debug version of the corresponding assembly line!
Single step the Debug version of the corresponding assembly is better than one thousand lines of single-step Release version corresponding to the assembly line!
Will not step the Release version of the corresponding assembly? In you want to step the Release version of C/C + + code snippets in the front of the temporarily add DebugBreak (); Rebuild all, and then run in the IDE, (the average person I don't tell him! nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related