本文整理汇总了C++中TranslateMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ TranslateMessage函数的具体用法?C++ TranslateMessage怎么用?C++ TranslateMessage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TranslateMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
/*
//MT4|ASK!EURUSD
char szApp[] = "MT4";
char szTopic[] = "ASK";
//char szCmd1[] = "[APP.MINIMIZE()]";
char szItem1[] = "USDJPY"; char szDesc1[] = "A1 Contains: ";
char szItem2[] = "USDCHF"; char szDesc2[] = "A2 Contains: ";
//char szItem3[] = "R3C1"; char szData3[] = "Data from DDE Client";
//char szCmd2[] = "[SELECT(\"R3C1\")][FONT.PROPERTIES(,\"Bold\")][SAVE()][QUIT()]";
*/
//DDE Initialization
UINT iReturn;
iReturn = DdeInitialize(&idInst, (PFNCALLBACK)DdeCallback,
APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0 );
if (iReturn!=DMLERR_NO_ERROR)
{
printf("DDE Initialization Failed: 0x%04x\n", iReturn);
Sleep(1500);
return 0;
}
//Start DDE Server and wait for it to become idle.
//HINSTANCE hRet = ShellExecute(0, "open", szTopic, 0, 0, SW_SHOWNORMAL);
//if ((int)hRet < 33)
//{
// printf("Unable to Start DDE Server: 0x%04x\n", hRet);
// Sleep(1500); DdeUninitialize(idInst);
// return 0;
//}
//Sleep(1000);
//DDE Connect to Server using given AppName and topic.
HCONV hConv;
hszApp = DdeCreateStringHandle(idInst, szApp, 0);
hszTopic = DdeCreateStringHandle(idInst, szTopic, 0);
hConv = DdeConnect(idInst, hszApp, hszTopic, NULL);
DdeFreeStringHandle(idInst, hszApp);
DdeFreeStringHandle(idInst, hszTopic);
if (hConv == NULL)
{
printf("DDE Connection Failed.\n");
Sleep(1500); DdeUninitialize(idInst);
return 0;
}
//Execute commands/requests specific to the DDE Server.
//DDEExecute(idInst, hConv, szCmd1);
DDERequest(idInst, hConv, szItem1, szDesc1);
DDERequest(idInst, hConv, szItem2, szDesc2);
//DDEPoke(idInst, hConv, szItem3, szData3);
//DDEExecute(idInst, hConv, szCmd2);
BOOL bRet;
MSG msg;
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//DDE Disconnect and Uninitialize.
DdeDisconnect(hConv);
DdeUninitialize(idInst);
Sleep(3000);
return 1;
}
示例2: SampleMain
//.........这里部分代码省略.........
true,
800);
map.MapBool(ButtonHoldGesture, hg->GetDeviceId(), gainput::HoldTriggered);
gainput::TapGesture* tg = manager.CreateAndGetDevice<gainput::TapGesture>();
GAINPUT_ASSERT(tg);
tg->Initialize(touchId, gainput::Touch0Down,
500);
map.MapBool(ButtonTapGesture, tg->GetDeviceId(), gainput::TapTriggered);
gainput::PinchGesture* pg = manager.CreateAndGetDevice<gainput::PinchGesture>();
GAINPUT_ASSERT(pg);
pg->Initialize(touchId, gainput::Touch0Down,
touchId, gainput::Touch0X,
touchId, gainput::Touch0Y,
touchId, gainput::Touch1Down,
touchId, gainput::Touch1X,
touchId, gainput::Touch1Y);
map.MapBool(ButtonPinching, pg->GetDeviceId(), gainput::PinchTriggered);
map.MapFloat(ButtonPinchScale, pg->GetDeviceId(), gainput::PinchScale);
gainput::RotateGesture* rg = manager.CreateAndGetDevice<gainput::RotateGesture>();
GAINPUT_ASSERT(rg);
rg->Initialize(touchId, gainput::Touch0Down,
touchId, gainput::Touch0X,
touchId, gainput::Touch0Y,
touchId, gainput::Touch1Down,
touchId, gainput::Touch1X,
touchId, gainput::Touch1Y);
map.MapBool(ButtonRotating, rg->GetDeviceId(), gainput::RotateTriggered);
map.MapFloat(ButtonRotateAngle, rg->GetDeviceId(), gainput::RotateAngle);
bool doExit = false;
while (!SfwIsDone() && !doExit)
{
manager.Update();
#if defined(GAINPUT_PLATFORM_LINUX)
XEvent event;
while (XPending(SfwGetXDisplay()))
{
XNextEvent(SfwGetXDisplay(), &event);
manager.HandleEvent(event);
if (event.type == DestroyNotify || event.type == ClientMessage)
{
doExit = true;
}
}
#elif defined(GAINPUT_PLATFORM_WIN)
MSG msg;
while (PeekMessage(&msg, SfwGetHWnd(), 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
manager.HandleMessage(msg);
}
#endif
SfwUpdate();
if (map.GetBoolWasDown(ButtonConfirm))
{
SFW_LOG("Confirmed!\n");
SFW_LOG("Memory: %u allocs, %u deallocs, %u used bytes\n", static_cast<unsigned>(allocator.GetAllocateCount()), static_cast<unsigned>(allocator.GetDeallocateCount()), static_cast<unsigned>(allocator.GetAllocatedMemory()));
}
if (map.GetBoolWasDown(ButtonConfirmDouble))
{
SFW_LOG("Confirmed doubly!\n");
}
if (map.GetBoolWasDown(ButtonConfirmExtra))
{
SFW_LOG("Confirmed alternatively!\n");
}
if (map.GetBool(ButtonHoldGesture))
{
SFW_LOG("Hold triggered!\n");
}
if (map.GetBoolWasDown(ButtonTapGesture))
{
SFW_LOG("Tapped!\n");
}
if (map.GetBool(ButtonPinching))
{
SFW_LOG("Pinching: %f\n", map.GetFloat(ButtonPinchScale));
}
if (map.GetBool(ButtonRotating))
{
SFW_LOG("Rotation angle: %f\n", map.GetFloat(ButtonRotateAngle));
}
}
SfwCloseWindow();
}
示例3: _tWinMain
//.........这里部分代码省略.........
langDLL.Close();
return 0;
}
MSG msg;
hInst = hInstance;
INITCOMMONCONTROLSEX used = {
sizeof(INITCOMMONCONTROLSEX),
ICC_STANDARD_CLASSES | ICC_BAR_CLASSES | ICC_WIN95_CLASSES
};
InitCommonControlsEx(&used);
// load the cursors we need
curHand = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
curHandDown = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANDOWNCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
std::unique_ptr<CMainWindow> mainWindow(new CMainWindow(hResource));
mainWindow->SetRegistryPath(_T("Software\\TortoiseGit\\TortoiseIDiffWindowPos"));
std::wstring leftfile = parser.HasVal(_T("left")) ? parser.GetVal(_T("left")) : _T("");
std::wstring rightfile = parser.HasVal(_T("right")) ? parser.GetVal(_T("right")) : _T("");
if ((leftfile.empty()) && (lpCmdLine[0] != 0))
{
int nArgs;
LPWSTR * szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (szArglist)
{
if (nArgs == 3)
{
// Four parameters:
// [0]: Program name
// [1]: left file
// [2]: right file
if (PathFileExists(szArglist[1]) && PathFileExists(szArglist[2]))
{
leftfile = szArglist[1];
rightfile = szArglist[2];
}
}
}
// Free memory allocated for CommandLineToArgvW arguments.
LocalFree(szArglist);
}
mainWindow->SetLeft(leftfile.c_str(), parser.HasVal(_T("lefttitle")) ? parser.GetVal(_T("lefttitle")) : _T(""));
mainWindow->SetRight(rightfile.c_str(), parser.HasVal(_T("righttitle")) ? parser.GetVal(_T("righttitle")) : _T(""));
if (parser.HasVal(L"base"))
mainWindow->SetSelectionImage(FileTypeBase, parser.GetVal(L"base"), parser.HasVal(L"basetitle") ? parser.GetVal(L"basetitle") : L"");
if (parser.HasVal(L"mine"))
mainWindow->SetSelectionImage(FileTypeMine, parser.GetVal(L"mine"), parser.HasVal(L"minetitle") ? parser.GetVal(L"minetitle") : L"");
if (parser.HasVal(L"theirs"))
mainWindow->SetSelectionImage(FileTypeTheirs, parser.GetVal(L"theirs"), parser.HasVal(L"theirstitle") ? parser.GetVal(L"theirstitle") : L"");
if (parser.HasVal(L"result"))
mainWindow->SetSelectionResult(parser.GetVal(L"result"));
if (mainWindow->RegisterAndCreateWindow())
{
HACCEL hAccelTable = LoadAccelerators(hResource, MAKEINTRESOURCE(IDR_TORTOISEIDIFF));
if (!parser.HasVal(L"left") && parser.HasVal(L"base") && !parser.HasVal(L"mine") && !parser.HasVal(L"theirs"))
{
PostMessage(*mainWindow, WM_COMMAND, ID_FILE_OPEN, 0);
}
if (parser.HasKey(_T("overlay")))
{
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_OVERLAPIMAGES, 0);
}
if (parser.HasKey(_T("fit")))
{
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0);
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0);
}
if (parser.HasKey(_T("fitwidth")))
{
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0);
}
if (parser.HasKey(_T("fitheight")))
{
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0);
}
if (parser.HasKey(_T("showinfo")))
{
PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_IMAGEINFO, 0);
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(*mainWindow, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
langDLL.Close();
DestroyCursor(curHand);
DestroyCursor(curHandDown);
CoUninitialize();
return 1;
}
示例4: WinMain
//.........这里部分代码省略.........
BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel;
BitMapInfo.bmiHeader.biCompression = BI_RGB;
BackBuffer = malloc(BufferWidth * BufferHeight * BytesPerPixel);
//if (BytesPerPixel == 1)
{
FILE *Palette = fopen("palette.lmp", "rb");
void *RawData = malloc(256 * 3);
unsigned char* PaletteData = RawData;
size_t Ret = fread(PaletteData, 1, 768, Palette);
for (int i = 0; i < 256; i++)
{
BitMapInfo.acolors[i].rgbRed = *PaletteData++;
BitMapInfo.acolors[i].rgbGreen = *PaletteData++;
BitMapInfo.acolors[i].rgbBlue = *PaletteData++;
}
free(RawData);
fclose(Palette);
}
FILE * Disc = fopen("DISC.lmp", "rb");
int DiscWidth, DiscHeight;
size_t RetVal = fread(&DiscWidth, 1, 4, Disc);
RetVal = fread(&DiscHeight, 1, 4, Disc);
void* DiscData = malloc(DiscWidth * DiscHeight);
RetVal = fread(DiscData, 1, DiscWidth * DiscHeight, Disc);
fclose(Disc);
FILE *Pause = fopen("pause.lmp", "rb");
int PauseWidth, PauseHeight;
RetVal = fread(&PauseWidth, 1, 4, Pause);
RetVal = fread(&PauseHeight, 1, 4, Pause);
void *PauseData = malloc(PauseWidth * PauseHeight);
RetVal = fread(PauseData, 1, PauseWidth * PauseHeight, Pause);
fclose(Pause);
MSG msg;
while (Running)
{
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (BytesPerPixel == 4)
{
int *MemoryWalker = (int*)BackBuffer;
for (int Height = 0; Height < BufferHeight; Height++)
{
for (int Width = 0; Width < BufferWidth; Width++)
{
unsigned char Red = rand() % 256;
unsigned char Green = rand() % 256;
unsigned char Blue = rand() % 256;
*MemoryWalker++ = ((Red << 16) | (Green << 8) | Blue);
}
}
DrawPic32(10, 10, DiscWidth, DiscHeight, DiscData, BackBuffer);
DrawPic32(100, 100, PauseWidth, PauseHeight, PauseData, BackBuffer);
//DrawRect(10, 10, 300, 150, 255, 0, 255, BackBuffer);
}
else if (BytesPerPixel == 1)
{
unsigned char *MemoryWalker = BackBuffer;
for (int Height = 0; Height < BufferHeight; Height++)
{
for (int Width = 0; Width < BufferWidth; Width++)
{
*MemoryWalker++ = rand() % 256;
}
}
//DrawPic8(10, 10, DiscWidth, DiscHeight, DiscData, BackBuffer);
//DrawPic8(100, 100, PauseWidth, PauseHeight, PauseData, BackBuffer);
//DrawRect8(10, 10, 300, 150, 1, BackBuffer);
}
HDC dc = GetDC(MainWindow);
StretchDIBits(dc,
0, 0, WindowWidth, WindowHeight,
0, 0, BufferWidth, BufferHeight,
BackBuffer, (BITMAPINFO*)&BitMapInfo,
DIB_RGB_COLORS, SRCCOPY);
ReleaseDC(MainWindow, dc);
}
free(BackBuffer);
free(DiscData);
free(PauseData);
return EXIT_SUCCESS;
}
示例5: wWinMain
int WINAPI wWinMain ( HINSTANCE hInstance , HINSTANCE prevInstance , LPWSTR cmdLine , int cmdShow )
{
UNREFERENCED_PARAMETER ( prevInstance );
UNREFERENCED_PARAMETER ( cmdLine );
WNDCLASSEX wndClass = { 0 };
wndClass.cbSize = sizeof ( WNDCLASSEX );
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.hInstance = hInstance;
wndClass.hCursor = LoadCursor ( NULL , IDC_ARROW );
wndClass.hbrBackground = ( HBRUSH ) ( COLOR_WINDOW + 1 );
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = "DX11BookWindowClass";
if( !RegisterClassEx( &wndClass ))
{
return -1;
}
RECT rc = { 0 , 0 , 640 , 480 };
AdjustWindowRect( &rc , WS_OVERLAPPEDWINDOW , FALSE );
HWND hwnd = CreateWindowEx ( WS_EX_OVERLAPPEDWINDOW, "DX11BookWindowClass" , "Blank Direct3D 11 Window" , WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT , CW_USEDEFAULT , rc.right - rc.left , rc.bottom - rc.top , NULL , NULL , hInstance , NULL );
/*
HWND hwnd = CreateWindowA ( "DX11BookWindowClass" , "Blank Direct 3D 11 Window" , WS_OVERLAPPEDWINDOW , CW_USEDEFAULT , CW_USEDEFAULT , rc.right - rc.left ,
rc.bottom - rc.top , NULL , NULL , hInstance , NULL );
*/
if( !hwnd )
return -1;
ShowWindow( hwnd , cmdShow );
std :: auto_ptr< Dx11DemoBase >demo ( new ColorInversionDemo());
//Demo Initialize
bool result = demo ->Initialize ( hInstance , hwnd );
//Error reporting if there is an issue
if( result == false )
return -1;
MSG msg = { 0 };
while ( msg.message != WM_QUIT )
{
if( PeekMessage ( &msg , 0 , 0 , 0 , PM_REMOVE ))
{
TranslateMessage( & msg );
DispatchMessage ( & msg );
}
else
{
//Update and draw
demo ->Update (0.0f);
demo ->Render ( );
}
}
//demo shutdown
demo ->Shutdown( );
return static_cast<int>( msg.wParam );
}
示例6: ShowErrorPane
void ShowErrorPane(const char *text)
{
if (Window == NULL || ConWindow == NULL)
{
if (text != NULL)
{
MessageBox (Window, text,
GAMESIG " Fatal Error", MB_OK|MB_ICONSTOP|MB_TASKMODAL);
}
return;
}
if (StartScreen != NULL) // Ensure that the network pane is hidden.
{
StartScreen->NetDone();
}
if (text != NULL)
{
char caption[100];
mysnprintf(caption, countof(caption), "Fatal Error - "GAMESIG" %s "X64, GetVersionString());
SetWindowText (Window, caption);
ErrorIcon = CreateWindowEx (WS_EX_NOPARENTNOTIFY, "STATIC", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SS_OWNERDRAW, 0, 0, 0, 0, Window, NULL, g_hInst, NULL);
if (ErrorIcon != NULL)
{
SetWindowLong (ErrorIcon, GWL_ID, IDC_ICONPIC);
}
}
ErrorPane = CreateDialogParam (g_hInst, MAKEINTRESOURCE(IDD_ERRORPANE), Window, ErrorPaneProc, (LONG_PTR)NULL);
if (text != NULL)
{
CHARRANGE end;
CHARFORMAT2 oldformat, newformat;
PARAFORMAT2 paraformat;
// Append the error message to the log.
end.cpMax = end.cpMin = GetWindowTextLength (ConWindow);
SendMessage (ConWindow, EM_EXSETSEL, 0, (LPARAM)&end);
// Remember current charformat.
oldformat.cbSize = sizeof(oldformat);
SendMessage (ConWindow, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&oldformat);
// Use bigger font and standout colors.
newformat.cbSize = sizeof(newformat);
newformat.dwMask = CFM_BOLD | CFM_COLOR | CFM_SIZE;
newformat.dwEffects = CFE_BOLD;
newformat.yHeight = oldformat.yHeight * 5 / 4;
newformat.crTextColor = RGB(255,170,170);
SendMessage (ConWindow, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&newformat);
// Indent the rest of the text to make the error message stand out a little more.
paraformat.cbSize = sizeof(paraformat);
paraformat.dwMask = PFM_STARTINDENT | PFM_OFFSETINDENT | PFM_RIGHTINDENT;
paraformat.dxStartIndent = paraformat.dxOffset = paraformat.dxRightIndent = 120;
SendMessage (ConWindow, EM_SETPARAFORMAT, 0, (LPARAM)¶format);
SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)"\n");
// Find out where the error lines start for the error icon display control.
SendMessage (ConWindow, EM_EXGETSEL, 0, (LPARAM)&end);
ErrorIconChar = end.cpMax;
// Now start adding the actual error message.
SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)"Execution could not continue.\n\n");
// Restore old charformat but with light yellow text.
oldformat.crTextColor = RGB(255,255,170);
SendMessage (ConWindow, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&oldformat);
// Add the error text.
SendMessage (ConWindow, EM_REPLACESEL, FALSE, (LPARAM)text);
// Make sure the error text is not scrolled below the window.
SendMessage (ConWindow, EM_LINESCROLL, 0, SendMessage (ConWindow, EM_GETLINECOUNT, 0, 0));
// The above line scrolled everything off the screen, so pretend to move the scroll
// bar thumb, which clamps to not show any extra lines if it doesn't need to.
SendMessage (ConWindow, EM_SCROLL, SB_PAGEDOWN, 0);
}
BOOL bRet;
MSG msg;
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
MessageBox (Window, text,
GAMESIG " Fatal Error", MB_OK|MB_ICONSTOP|MB_TASKMODAL);
return;
}
else if (!IsDialogMessage (ErrorPane, &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
示例7: WinMain
int WINAPI WinMain( HINSTANCE hInstance, // Instance
HINSTANCE hPrevInstance, // Previous Instance
LPSTR lpCmdLine, // Command Line Parameters
int nCmdShow) // Window Show State
{
MSG msg; // Windows Message Structure
BOOL bDone = FALSE; // Bool Variable To Exit Loop
// Ask The User Which Screen Mode They Prefer
if (MessageBox(NULL, MSG_RUNINFULLSCREEN,
MSG_STARTFULLSCREEN, MB_YESNO | MB_ICONQUESTION) == IDNO)
{
g_bFullscreen = FALSE; // Windowed Mode
}
// Create Our OpenGL Window
if (!CreateGLWindow(WINDOW_TITLE, WINDOW_WIDTH,
WINDOW_HEIGHT, WINDOW_BIT, g_bFullscreen))
{
return 0; // Quit If Window Was Not Created
}
while (!bDone) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message == WM_QUIT) // Have We Received A Quit Message?
{
bDone = TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if (g_bActive) // Program Active?
{
if (g_bKeysArr[VK_ESCAPE]) // Was ESC Pressed?
{
bDone = TRUE; // ESC Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
DrawGLScene(); // Draw The Scene
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
if (g_bKeysArr['L'] && !g_bLPress) // L key being pressed not held?
{
g_bLPress = TRUE; // Become TRUE
g_bLight = !g_bLight; // Toggle light TRUE/FALSE
if (!g_bLight)
{
glDisable(GL_LIGHTING); // Disable lighting
}
else
{
glEnable(GL_LIGHTING); // Enable lighting
}
}
if (!g_bKeysArr['L']) // Has L key been released?
{
g_bLPress = FALSE; // If so, become FALSE
}
if (g_bKeysArr['F'] && !g_bFPress) // Is F key being pressed not held?
{
g_bFPress = TRUE;
g_uFilter += 1;
if (g_uFilter > 2)
{
g_uFilter = 0;
}
}
if (!g_bKeysArr['F'])
{
g_bFPress = FALSE;
}
}
}
if (g_bKeysArr[VK_F1]) // Is F1 Being Pressed?
{
g_bKeysArr[VK_F1] = FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
g_bFullscreen = !g_bFullscreen; // Toggle Full screen / Windowed Mode
// Recreate Our OpenGL Window
if (!CreateGLWindow(WINDOW_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BIT, g_bFullscreen))
{
return 0; // Quit If Window Was Not Created
}
}
// Handle move left-right
if (g_bKeysArr[VK_LEFT])
{
g_bKeysArr[VK_LEFT] = FALSE;
g_MoveX -= g_MDeltaX;
}
if (g_bKeysArr[VK_RIGHT])
//.........这里部分代码省略.........
示例8: WinMain
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX wcex;
HMENU menu, popupMenu;
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_APPLICATION));
wcex.hCursor = LoadCursor(hInstance, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
hInst = hInstance; // Store instance handle in our global variable
// The parameters to CreateWindow explained:
// szWindowClass: the name of the application
// szTitle: the text that appears in the title bar
// WS_SYSMENU: the type of window to create
// CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y)
// 500, 100: initial size (width, length)
// NULL: the parent of this window
// TODO: // NULL: this application does not have a menu bar
// hInstance: the first parameter from WinMain
// NULL: not used in this application
hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
WindowWidth, WindowHeight,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
_T("Call to CreateWindow failed!"),
_T("Win32 Guided Tour"),
NULL);
return 1;
}
hButtonRefresh = CreateWindow(L"button", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 0, 0, 32, 32, hWnd, (HMENU)IDC_BUTTON_REFRESH, hInst, NULL);
hButtonClear = CreateWindow(L"button", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 0, 32, 32, 32, hWnd, (HMENU)IDC_BUTTON_CLEAR, hInst, NULL);
// The parameters to ShowWindow explained:
// hWnd: the value returned from CreateWindow
// nCmdShow: the fourth parameter from WinMain
ShowWindow(hWnd,
nCmdShow);
UpdateWindow(hWnd);
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
示例9: WinMain
//.........这里部分代码省略.........
else
pLog->Log(cfg.GamePlayAssetFile + " (audio) was loaded successfully!");
*/
/*
if(pAudio->IsValidSound() == true)
pLog->Log("Audio system initialized (size)", pAudio->Size());
else
pLog->Log("Audio failure!");
*/
//log all audio files
if(cfg.LogDebugInfo == true){
pLog->Log("************************** Audio Files Loaded **************");
// for(int i = 0; i < pAudio->Size(); i++){
// pLog->Log(pAudio->GetFilename(i));
// }
pLog->Log("");
}
// enter the main loop
//************************************** M A I N L O O P *****************
MSG msg;
pLog->Log("Entering Main Control Loop");
float timeDiff = 0.0f;
g_pCurrent->Activate(gameData, cfg, con);
//*********************
// PYRO
//con.InitializePyro();
while(g_bRunning)
{
DWORD starting_point = GetTickCount();
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//manage frame count determination
gLoopCount++;
if(gTimerFPS.getTimer(1.0) == true){
gameData.m_FPS = static_cast<float>(gLoopCount);
gLoopCount = 0;
gSecondCount++;
if(gSecondCount > 30){ //log every 30 seconds
gSecondCount = 0;
if(cfg.LogDebugInfo == true)
pLog->Log("FPS",gameData.m_FPS);
}
}
//stores mouse button status for use in other classes
gameData.m_bLeftMouseDown = mouse.LeftButtonDown();
gameData.m_bRightMouseDown = mouse.RightButtonDown();
//update
g_pLast = g_pCurrent;
g_pNext = g_pCurrent->Update(timerGame.getTimeDifference(), gameData, cfg, con);
if(g_pNext == g_pStateQuit)
g_bRunning = false;
else if(NULL != g_pNext)
{
if(g_pNext != g_pLast){
g_pLast->Deactivate(gameData, cfg, con);
g_pCurrent = g_pNext;
g_pCurrent->Activate(gameData, cfg, con);
}
}
//render
g_pCurrent->Render(con, gameData, cfg);
// check the 'escape' key
if(g_bRunning == false){
gExitProgram = true;
PostMessage(hWnd, WM_DESTROY, 0, 0);
}
}
pLog->Log("Exited main loop");
//**************************
// PYRO
//con.ClosePyro();
// clean up DirectX and COM
con.CleanupDirectX();
Shutdown();
pLog->Log("DirectX Cleaned Up");
pLog->Log("Shutdown complete!");
pLog->Log("***************************************");
pLog->Log(" Program Terminated Normally");
pLog->Log("***************************************");
return static_cast<int>(msg.wParam);
}
示例10: mswin_display_RIP_window
void mswin_display_RIP_window (HWND hWnd)
{
MSG msg;
RECT rt;
PNHRIPWindow data;
HWND mapWnd;
RECT riprt;
RECT clientrect;
RECT textrect;
HDC hdc;
HFONT OldFont;
data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA);
GetNHApp()->hPopupWnd = hWnd;
mapWnd = mswin_hwnd_from_winid(WIN_MAP);
if( !IsWindow(mapWnd) ) mapWnd = GetNHApp()->hMainWnd;
GetWindowRect(mapWnd, &rt);
GetWindowRect(hWnd, &riprt);
GetClientRect (hWnd, &clientrect);
textrect = clientrect;
textrect.top += RIP_OFFSET_Y;
textrect.left += RIP_OFFSET_X;
textrect.right -= RIP_OFFSET_X;
if (data->window_text)
{
hdc = GetDC (hWnd);
OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
SelectObject (hdc, OldFont);
ReleaseDC(hWnd, hdc);
}
if (textrect.right - textrect.left > RIP_WIDTH)
clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
else
clientrect.right = textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
clientrect.bottom = textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
GetWindowRect (GetDlgItem(hWnd, IDOK), &textrect);
textrect.right -= textrect.left;
textrect.bottom -= textrect.top;
clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
riprt.right -= riprt.left;
riprt.bottom -= riprt.top;
riprt.right += clientrect.right;
riprt.bottom += clientrect.bottom;
rt.left += (rt.right - rt.left - riprt.right) / 2;
rt.top += (rt.bottom - rt.top - riprt.bottom) / 2;
MoveWindow(hWnd, rt.left, rt.top, riprt.right, riprt.bottom, TRUE);
GetClientRect (hWnd, &clientrect);
MoveWindow (GetDlgItem(hWnd, IDOK),
(clientrect.right - clientrect.left - textrect.right) / 2,
clientrect.bottom - textrect.bottom - RIP_OFFSET_Y, textrect.right, textrect.bottom, TRUE);
ShowWindow(hWnd, SW_SHOW);
while( IsWindow(hWnd) &&
GetMessage(&msg, NULL, 0, 0)!=0 ) {
if( !IsDialogMessage(hWnd, &msg) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
GetNHApp()->hPopupWnd = NULL;
}
示例11: WinMain
//.........这里部分代码省略.........
}
#else
/* Load DDL's from DRIVERS section in system.ini
*/
GetPrivateProfileString( (LPSTR)"boot", /* [Boot] section */
(LPSTR)"drivers", /* Drivers= */
(LPSTR)"", /* Default if no match */
szBuffer, /* Return buffer */
sizeof(szBuffer),
(LPSTR)"system.ini" );
if (!*szBuffer) {
goto Done;
}
bFinished = FALSE;
iStart = 0;
while (!bFinished) {
iEnd = iStart;
while (szBuffer[iEnd] && (szBuffer[iEnd] != ' ') &&
(szBuffer[iEnd] != ',')) {
iEnd++;
}
if (szBuffer[iEnd] == NULL) {
bFinished = TRUE;
}
else {
szBuffer[iEnd] = NULL;
}
/* Load and enable the driver.
*/
OpenDriver( &(szBuffer[iStart]), NULL, NULL );
iStart = iEnd + 1;
}
Done:
#endif
/*
* Look for a debug= line in the [boot] section of SYSTEM.INI
* If present it is the 16 bit MultiMedia interface, so load it
*/
if ( WOWQueryDebug() & 0x0001 ) {
pchWOWDEB = "WOWDEB.EXE";
} else {
pchWOWDEB = "";
}
GetPrivateProfileString((LPSTR)"boot", (LPSTR)"debug",pchWOWDEB, aszWOWDEB, sizeof(aszWOWDEB), (LPSTR)"SYSTEM.INI");
aszWOWDEB[sizeof(aszWOWDEB)-1] = '\0';
if ( lstrlen(pchWOWDEB) != 0 ) {
WinExec((LPSTR)aszWOWDEB,SW_SHOW);
}
#if 0
/* Preload winspool.exe. Apps will keep loading and freeing it
* which is slow. We might as well load it now so the reference
* count is 1 so it will never be loaded or freed
*/
//
// Disabled load of winspool.exe to save 8k. Size vs. speed,
// which one do we care about? Right now, size!
//
LoadLibrary("WINSPOOL.EXE");
#endif
// Always load SHELL.DLL, FileMaker Pro and Lotus Install require it.
LoadLibrary("SHELL.DLL");
//
// Start any apps pending in basesrv queue
//
while (StartRequestedApp() && gfSharedWOW) {
/* null stmt */ ;
}
while (1) {
if (!WowWaitForMsgAndEvent(ghwndMain) &&
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) &&
msg.message != WM_WOWEXECHEARTBEAT )
{
if (msg.message != WM_QUIT) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return 1;
}
示例12: main
int main(int argc, char *argv[])
{
CommandLineArgs args(argc, argv);
if (!args.ok) {
PrintUsage();
return 1;
}
// Print init info
std::cout << "AbsoluteTouch v" << VERSION_NAME << std::endl;
std::cout << "Author: " << AUTHOR << std::endl;
std::cout << "Project page: " << PROJECT_URL << std::endl;
std::cout << "--------------------------------------------------" << std::endl;
std::cout << "Starting..." << std::endl;
// Initialize COM
CCoInitialize init;
// Set cleanup handler
g_mainThreadId = GetCurrentThreadId();
if (!SetConsoleCtrlHandler(OnConsoleSignal, TRUE)) {
std::cerr << "Error: failed to register console control handler" << std::endl;
CleanUp();
return 1;
}
std::cout << "Registered console control handler" << std::endl;
// Initialize touchpad manager
try {
g_touchpadManager = new TouchpadManager();
} catch (const TouchpadInitException &e) {
std::cerr << "Error: could not initialize touchpad manager" << std::endl;
std::cerr << e.what() << std::endl;
CleanUp();
return 1;
}
std::cout << "Initialized touchpad manager" << std::endl;
// Acquire exclusive touchpad access
if (!g_touchpadManager->Acquire()) {
std::cerr << "Error: could not acquire exclusive touchpad access" << std::endl;
CleanUp();
return 1;
}
std::cout << "Acquired exclusive touchpad access" << std::endl;
// Register touchpad touch callback
g_touchCallback = new AbsoluteTouchCallback();
g_touchCallback->SetScreenRect(Rect<long>(0, 0, 65535, 65535).scale(args.screenRect));
g_touchCallback->SetTouchpadRect(g_touchpadManager->GetTouchpadRect().scale(args.touchpadRect));
g_touchCallback->SetSmoothingWeight(args.smoothingWeight);
g_touchCallback->SetSendClick(args.sendClick);
g_touchpadManager->SetTouchCallback(g_touchCallback);
std::cout << "Registered touch listener" << std::endl;
// Enable touchpad if option was specified
if (args.manageTouchpad && !g_touchpadManager->IsTouchpadEnabled()) {
g_touchpadManager->SetTouchpadEnabled(true);
g_touchpadEnabledModified = true;
std::cout << "Enabled touchpad" << std::endl;
}
// Print usage instructions
std::cout << "--------------------------------------------------" << std::endl;
std::cout << "Initialization complete, absolute touch mode enabled!" << std::endl;
std::cout << "Keep this window open until you wish to exit absolute touch mode." << std::endl;
std::cout << "To exit the program, you can use CTRL-C." << std::endl;
// Main message loop
MSG msg;
BOOL ret;
while ((ret = GetMessage(&msg, nullptr, 0, 0)) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
CleanUp();
g_cleanupFinished = true;
return 0;
}
示例13: WinMain
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASSEX winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
HDC hdc; // graphics device context
// first fill in the window class stucture
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// save hinstance in global
hinstance_app = hinstance;
// register the window class
if (!RegisterClassEx(&winclass))
return(0);
// create the window
if (!(hwnd = CreateWindowEx(NULL, // extended style
WINDOW_CLASS_NAME, // class
"DirectDraw 24-Bit Bitmap Loading", // title
WS_POPUP | WS_VISIBLE,
0,0, // initial x,y
SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height
NULL, // handle to parent
NULL, // handle to menu
hinstance,// instance of this application
NULL))) // extra creation parms
return(0);
// save main window handle
main_window_handle = hwnd;
// initialize game here
Game_Init();
// enter main event loop
while(TRUE)
{
// test if there is a message in queue, if so get it
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
// test if this is a quit
if (msg.message == WM_QUIT)
break;
// translate any accelerator keys
TranslateMessage(&msg);
// send the message to the window proc
DispatchMessage(&msg);
} // end if
// main game processing goes here
Game_Main();
} // end while
// closedown game here
Game_Shutdown();
// return to Windows like this
return(msg.wParam);
} // end WinMain
示例14: WinMain
int PASCAL WinMain( HINSTANCE instance,
HINSTANCE previous_instance,
LPSTR cmd_line,
int cmd_show )
{
//
// Win32 locals.
//
HWND window = 0;
MSG msg;
//
// Try to create our window.
//
window = Build_window_handle( instance,
previous_instance );
if ( !window )
{
MessageBox( 0,
"Error creating window.",
"Windows",
MB_OK | MB_ICONSTOP );
return( 1 );
}
//
// Tell Bink to use DirectSound (must be before BinkOpen)!
//
BinkSoundUseDirectSound( 0 );
//
// Try to open the Bink file.
//
Bink = BinkOpen( cmd_line, 0 );
if ( !Bink )
{
MessageBox( window,
BinkGetError( ),
"Bink Error",
MB_OK | MB_ICONSTOP );
DestroyWindow( window );
return( 3 );
}
//
// Try to open the Bink buffer.
//
Bink_buffer = BinkBufferOpen( window, Bink->Width, Bink->Height, 0 );
if ( !Bink_buffer )
{
MessageBox( window,
BinkBufferGetError( ),
"Bink Error",
MB_OK | MB_ICONSTOP );
DestroyWindow( window );
BinkClose( Bink );
return( 4 );
}
//
// Size the window such that its client area exactly fits our Bink movie.
//
SetWindowPos( window, 0,
0, 0,
Bink_buffer->WindowWidth,
Bink_buffer->WindowHeight,
SWP_NOMOVE );
//
// Now display the window and start the message loop.
//
ShowWindow( window, cmd_show );
for ( ; ; )
{
//
// Are there any messages to handle?
//
if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) )
{
//
// Yup, handle them.
//
if ( msg.message == WM_QUIT )
break;
TranslateMessage( &msg );
DispatchMessage( &msg );
//.........这里部分代码省略.........
示例15: _tWinMain
int APIENTRY _tWinMain(HINSTANCE hinst, HINSTANCE foo1, LPTSTR foo2, int foo3) {
MSG msg;
WNDCLASSEX wcex = {sizeof(wcex)};
HANDLE htray;
HMENU hmenu;
MENUITEMINFO mi = {sizeof(mi)};
INITCOMMONCONTROLSEX icex;
RECT rect;
int style;
HWND hwnd;
wcex.lpfnWndProc = WndProc;
wcex.lpszClassName = WINDOW_CLASS;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
RegisterClassEx(&wcex);
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icex);
hwnd = CreateWindowEx(WS_EX_NOACTIVATE | WS_EX_TOPMOST, WINDOW_CLASS, WINDOW_TITLE, 0,
0, 0, 0, 0, NULL, NULL, hinst, NULL);
if (!hwnd) return 1;
style = GetWindowLong(hwnd, GWL_STYLE);
if (style & WS_CAPTION) {
style ^= WS_CAPTION;
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
hcal = CreateWindowEx(0, MONTHCAL_CLASS, _T(""),
WS_CHILD | WS_VISIBLE | MCS_NOTODAY | MCS_NOTRAILINGDATES | MCS_SHORTDAYSOFWEEK | MCS_NOSELCHANGEONNAV,
0, 0, 0, 0, hwnd, NULL, hinst, NULL);
MonthCal_GetMinReqRect(hcal, &rect);
SetWindowPos(hcal, NULL, 0, 0, rect.right, rect.bottom, SWP_NOZORDER | SWP_NOMOVE);
SetWindowPos(hwnd, NULL, 0, 0, rect.right, rect.bottom, SWP_NOZORDER | SWP_NOMOVE);
tti.hwnd = hwnd;
tti.hcal = hcal;
tti.hnotify = CreateEvent(NULL, TRUE, FALSE, NULL);
tti.exit = FALSE;
htray = CreateThread(NULL, 0, &TrayThreadProc, &tti, 0, NULL);
if (!htray) return 1;
hsubmenu = CreateMenu();
mi.fMask = MIIM_STRING | MIIM_ID;
mi.wID = 1;
mi.dwTypeData = EXIT_STRING;
InsertMenuItem(hsubmenu, 0, TRUE, &mi);
hmenu = CreateMenu();
mi.fMask = MIIM_SUBMENU;
mi.hSubMenu = hsubmenu;
InsertMenuItem(hmenu, 0, TRUE, &mi);
WM_TASKBARCREATED = RegisterWindowMessageA(_T("TaskbarCreated"));
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
DestroyMenu(hmenu);
DestroyMenu(hsubmenu);
WaitForSingleObject(htray, 1000);
CloseHandle(htray);
return (int)msg.wParam;
}