I'm learning C++. I wonder is any C++ application have HWND. Example bellow app, with no window created. If it have, how I can get its HWND? Thank you very much!

#include <windows.h>

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow )
{
    MSG msg;
    while( GetMessage( &msg, NULL, 0, 0 ) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
}
有帮助吗?

解决方案 2

You need to create one.

check out CreateWindowEx and ShowWindow

其他提示

"I'm learning C++. I wonder is any C++ application have HWND." The shortest answer is no. HWND is a defined type in a library used to write Windows applications. C++ is a language that can be used to do that as long as you have library that gives you functions (including HWND type.)

You can write programs for CMD prompt or for Unix which have nothing to do with Windows. Try this C style program. Copy text below to a.cpp file, and compile it to generate a.exe:

#include <stdio.h>
int main()
{
    printf( "Hello world\n" ) ;
    return 0 ;
}

When you run cmd, change directory to where a.exe is, and run a.exe then you will see:

Hello world

If you plan on learning C++ you don't need to write Windows applications. You can write CMD or Linux programs. Find a good book on the C++ subject. Good luck!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top