GetMainWindowHandle は DxLib_Init の後でないと無効だと思います。
おそらく、ウィンドウを表示したままタスクバーの表示を消したいのだと思いますが、
私の思いつく範囲でやってみましたが、前途多難な感じでした。
//- 以下、テストコード -//
#include "DxLib.h"
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
TCHAR* szTitle = _T( "Hide Window" );
TCHAR* szWindowClass = _T( "Hide Window" );
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( NULL, IDI_APPLICATION );
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
RegisterClassEx( &wcex );
HWND hWndHide = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPED & ~WS_VISIBLE,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL
);
if ( !hWndHide )
return FALSE;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect( &rc, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, FALSE );
HWND hWndChild = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, hWndHide, NULL, hInstance, NULL
);
if ( !hWndChild )
return FALSE;
SetUserWindow( hWndChild );
//ChangeWindowMode( TRUE );
SetWindowText( _T("DxLib:") DXLIB_VERSION_STR );
if ( DxLib_Init( ) == -1 ) return -1;
ShowWindow( hWndChild, SW_SHOW );
int white = GetColor( 255, 255, 255 );
// 最初はDxLibの作ったウィンドウを子ウィンドウにしようとしましたがうまくいきませんでした。
// がんばればうまくいくかも?
//SetParent( GetMainWindowHandle( ), hWndHide );
//LONG Style = GetWindowLong( GetMainWindowHandle( ), GWL_STYLE );
//Style = (Style & ~WS_POPUP) | WS_CHILD | WS_VISIBLE;
//SetWindowLong( GetMainWindowHandle( ), GWL_STYLE, Style );
//SetWindowStyleMode( Style );
MSG msg;
SetDrawScreen( DX_SCREEN_BACK );
while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 ) {
ClearDrawScreen( );
DrawFormatString( 0, 0, white, _T( "TEST" ) );
ScreenFlip( );
if ( !GetMessage( &msg, NULL, 0, 0 ) ) {
break;
}
TranslateMessage( &msg );
DispatchMessage( &msg );
}
DxLib_End( );
return 0;
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch ( message ) {
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}