C + + methods for obtaining information in other program form controls

Source: Internet
Author: User

The example in this article describes how C + + obtains information in other program form controls. Share to everyone for your reference. The specific analysis is as follows:

This shows a way to get information about other program form controls,

Use the FindWindow API to find the text box handle and get the text with SendMessage (Wm_gettext)

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The #include <windows.h> BOOL CALLBACK enumchildproc (H WND Hwnd,lparam LPARAM); int WINAPI WinMain (hinstance hinstance,hinstance hprevinstance,lpstr lpcmdline,int ncmdshow) {char classname[]= Notepad "; HWND Hwnd=::findwindow (classname,null); if (hWnd) {:: Enumchildwindows (hwnd,enumchildproc,0); return 0;} MessageBox (NULL, "fail!", "fail", MB_OK); return 0; BOOL CALLBACK Enumchildproc (HWND hwnd,lparam LPARAM) {char temp1[256],temp2[256];:: GetClassName (hwnd,temp1,255); if ( !::STRCMP (Temp1, "Edit")) {:: SendMessage (hwnd,wm_gettext,sizeof (TEMP2)/sizeof (char), (LPARAM) temp2); Handle to//edit, message, Receive buffer size, receive buffer pointer:: MessageBox (NULL,TEMP2, "get", MB_OK); return 0; }:: wsprintf (Temp2, "ClassName:%s", TEMP1); MessageBox (NULL,TEMP2, "CWnd", MB_OK); return true; }

I hope this article will help you with your C + + programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.