以下のテストコードでテストしてみましたが、特に問題ないように見受けられました。
//- 以下、テストコード (カレントの"default.bmp"を読み込みます) -//
#include "DxLib.h"
char szClassNme[] = "ウィンドウクラス・ネーム";
int QuitMessage = 0;
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
QuitMessage = 1;
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam );
}
return 0;
}
const int MAX_PATH_LEN = 1024;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow )
{
char CurentDir[MAX_PATH_LEN];
GetCurrentDirectory( MAX_PATH_LEN, CurentDir );
HWND hWnd;
MSG msg;
WNDCLASS myProg;
if( !hPreInst )
{
myProg.style =CS_HREDRAW | CS_VREDRAW;
myProg.lpfnWndProc =WndProc;
myProg.cbClsExtra =0;
myProg.cbWndExtra =0;
myProg.hInstance =hInstance;
myProg.hIcon =NULL;
myProg.hCursor =LoadCursor(NULL, IDC_ARROW);
myProg.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
myProg.lpszMenuName =NULL;
myProg.lpszClassName =szClassNme;
if( RegisterClass( &myProg ) == FALSE )
return FALSE ;
}
hWnd = CreateWindow(
szClassNme, "テストプログラム", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL );
ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
SetUserWindow( hWnd );
ChangeWindowMode( TRUE );
SetWindowText( "DxLib:" DXLIB_VERSION_STR );
if ( DxLib_Init( ) == -1 ) return -1;
int white = GetColor( 255, 255, 255 );
OPENFILENAME ofn = { };
char fullpath[MAX_PATH_LEN] = { };
char filename[MAX_PATH_LEN] = { };
const char defaultfile[] = "default.bmp";
const char *openfile = defaultfile;
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.hwndOwner = GetMainWindowHandle( );
ofn.lpstrFilter = "bmp(*.bmp)\0*.bmp\0\0";
ofn.lpstrFile = fullpath;
ofn.lpstrFileTitle = filename;
ofn.nMaxFile = MAX_PATH_LEN;
ofn.nMaxFileTitle = MAX_PATH_LEN;
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrTitle = "てすと";
ofn.lpstrDefExt = "bmp";
openfile = GetOpenFileName( &ofn ) ? ofn.lpstrFile : defaultfile;
SetCurrentDirectory( CurentDir );
int gh = LoadGraph( openfile );
SetDrawScreen( DX_SCREEN_BACK );
while ( ProcessMessage( ) == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 && QuitMessage == 0 ) {
ClearDrawScreen( );
DrawGraph( 0, 0, gh, TRUE );
DrawFormatString( 0, 0, white, "TEST" );
ScreenFlip( );
if ( CheckHitKey( KEY_INPUT_DELETE ) ) {
DeleteGraph( gh );
openfile = GetOpenFileName( &ofn ) ? ofn.lpstrFile : defaultfile;
SetCurrentDirectory( CurentDir );
gh = LoadGraph( openfile );
}
if ( PeekMessage( &msg, hWnd, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
DxLib_End( );
return 0;
}