| | |
::FindWindow()'s problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
Hihi..
I would like to ask about ::FindWindow's function..
I execute a program call ABC.exe..
I have coding like below..
HWND window = ::FindWindow("ABC", NULL);
but I get the window value is NULL..
may I know what is my mistake..??
I had execute the ABC program, suspose it can return me it's hwnd..
I didn't use the second variable from FindWindow's function because it's title is different..
pls advise..
thank you..
I would like to ask about ::FindWindow's function..
I execute a program call ABC.exe..
I have coding like below..
HWND window = ::FindWindow("ABC", NULL);
but I get the window value is NULL..
may I know what is my mistake..??
I had execute the ABC program, suspose it can return me it's hwnd..
I didn't use the second variable from FindWindow's function because it's title is different..
pls advise..
thank you..
•
•
•
•
Hihi..
I would like to ask about ::FindWindow's function..
I execute a program call ABC.exe..
I have coding like below..
HWND window = ::FindWindow("ABC", NULL);
but I get the window value is NULL..
may I know what is my mistake..??
I had execute the ABC program, suspose it can return me it's hwnd..
I didn't use the second variable from FindWindow's function because it's title is different..
pls advise..
thank you..
ABC.exe is windows application or a command line application?
Did you register any class or atom in ABC.exe by the name "ABC" by calling RegisterClass ? If so, are you using same class name in CreateWindow call in ABC.exe ?
If you have already done both of the above things verify if it is a problem with UICODE and ANSII version of the string. Make sure you are using either UNICODE or ANSII in both of the applications.
I know I am. Therefore I am.
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
thank you for replying..
I think I got confusing already..
I didn't call any RegisterClass or CreateWindow..
May I know that how do I call RegisterClass and CreateWindow..??
I think I got confusing already..
I didn't call any RegisterClass or CreateWindow..
May I know that how do I call RegisterClass and CreateWindow..??
•
•
•
•
Please do not get confused. FindWindow does not have do anything the name of the executable.
ABC.exe is windows application or a command line application?
Did you register any class or atom in ABC.exe by the name "ABC" by calling RegisterClass ? If so, are you using same class name in CreateWindow call in ABC.exe ?
If you have already done both of the above things verify if it is a problem with UICODE and ANSII version of the string. Make sure you are using either UNICODE or ANSII in both of the applications.
•
•
•
•
thank you for replying..
I think I got confusing already..
I didn't call any RegisterClass or CreateWindow..
May I know that how do I call RegisterClass and CreateWindow..??
This sample has 2 projects.
1) Windows Application.
2) Command Line App.
Windows Application calls
C++ Syntax (Toggle Plain Text)
RegisterClassEx
C++ Syntax (Toggle Plain Text)
ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FINDWINDOWSAMPLE)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_FINDWINDOWSAMPLE); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassEx(&wcex); }
This application uses this class to create a window.
C++ Syntax (Toggle Plain Text)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
It then registers a Private Message
C++ Syntax (Toggle Plain Text)
WM_MY_MESSAGE = RegisterWindowMessage(TEXT("WM_MY_MESSAGE"));
C++ Syntax (Toggle Plain Text)
if(message == WM_MY_MESSAGE) { MessageBox(hWnd,TEXT("Messsage From Command Line App"),TEXT("Message"),MB_OK); }
The comand line application simply calls
C++ Syntax (Toggle Plain Text)
FindWindow
C++ Syntax (Toggle Plain Text)
int _tmain(int argc, _TCHAR* argv[]) { HWND hWnd = NULL ; hWnd = FindWindow(szWindowClass,szWindowClass); if(!hWnd) { printf("FindWindow failed %d", GetLastError()); } WM_MY_MESSAGE = RegisterWindowMessage(TEXT("WM_MY_MESSAGE")); SendMessage(hWnd,WM_MY_MESSAGE,0,0); return 0; }
To run the sample.
1) Build both of the projects.
2) Run Windows Application.
3) Run Command Line application.
Please let me know if you have any questions.
I know I am. Therefore I am.
![]() |
Similar Threads
- FindWindow Problem (VB.NET)
- problem with report in notepad (Visual Basic 4 / 5 / 6)
- FindWindow Problems (on Windows 98/ME) (C++)
- How do I Execute multi programs (Visual Basic 4 / 5 / 6)
- Stopping Hardware (Visual Basic 4 / 5 / 6)
- problem with Sendkeys (Visual Basic 4 / 5 / 6)
- Sending keys to active window. (C++)
Other Threads in the C++ Forum
- Previous Thread: hosting an activeXcontrol container using ATL
- Next Thread: virtual void drive() = 0 What this means?
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





