本文整理汇总了C++中CreateWindowEx函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateWindowEx函数的具体用法?C++ CreateWindowEx怎么用?C++ CreateWindowEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateWindowEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Game_Genie_Window_CreateChildWindows
void Game_Genie_Window_CreateChildWindows(HWND hWnd)
{
// Description labels.
HWND lblInfoTitle, lblInfo;
// Strings
const char* strInfoTitle = "Information about Game Genie / Patch codes";
const char* strInfo =
"Both Game Genie codes and Patch codes are supported.\n"
"Check the box next to the code to activate it.\n"
"Syntax for Game Genie codes: XXXX-YYYY\n"
"Syntax for Patch codes: AAAAAA-DDDD (address-data)";
// Info Title
lblInfoTitle = CreateWindow(WC_STATIC, strInfoTitle,
WS_CHILD | WS_VISIBLE | SS_LEFT,
8, 8, 256, 16, hWnd, NULL, ghInstance, NULL);
SetWindowFont(lblInfoTitle, fntTitle, TRUE);
// Info
lblInfo = CreateWindow(WC_STATIC, strInfo,
WS_CHILD | WS_VISIBLE | SS_LEFT,
8, 24, wndWidth-16, 68, hWnd, NULL, ghInstance, NULL);
SetWindowFont(lblInfo, fntMain, TRUE);
// Code and Name boxes, plus "Add Code" button.
HWND lblCode, btnAddCode;
HWND lblName;
// Code label
lblCode = CreateWindow(WC_STATIC, "Code",
WS_CHILD | WS_VISIBLE | SS_LEFT,
8, 24+68+8, 32, 16, hWnd, NULL, ghInstance, NULL);
SetWindowFont(lblCode, fntMain, TRUE);
// Code entry
gg_txtCode = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | SS_LEFT | ES_AUTOHSCROLL,
8+32+8, 24+68+8, wndWidth - (8+32+8+64+8+8+16), 20,
hWnd, NULL, ghInstance, NULL);
SetWindowFont(gg_txtCode, fntMain, TRUE);
gg_txtCode_oldProc = (WNDPROC)SetWindowLongPtr(gg_txtCode, GWL_WNDPROC, (LONG_PTR)Game_Genie_TextBox_WndProc);
// Name label
lblName = CreateWindow(WC_STATIC, "Name",
WS_CHILD | WS_VISIBLE | SS_LEFT,
8, 24+68+8+24, 32, 16,
hWnd, NULL, ghInstance, NULL);
SetWindowFont(lblName, fntMain, TRUE);
// Name entry
gg_txtName = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | SS_LEFT | ES_AUTOHSCROLL,
8+32+8, 24+68+8+24, wndWidth - (8+32+8+64+8+8+16), 20,
hWnd, NULL, ghInstance, NULL);
SetWindowFont(gg_txtName, fntMain, TRUE);
gg_txtName_oldProc = (WNDPROC)SetWindowLongPtr(gg_txtName, GWL_WNDPROC, (LONG_PTR)Game_Genie_TextBox_WndProc);
// Add Code
btnAddCode = CreateWindow(WC_BUTTON, "&Add Code",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
wndWidth - (64+8+16), 24+68+8, 63+16, 20,
hWnd, IDC_BTN_ADD, ghInstance, NULL);
SetWindowFont(btnAddCode, fntMain, TRUE);
// ListView
gg_lstvCodes = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, "",
WS_CHILD | WS_VISIBLE | WS_TABSTOP | LVS_REPORT,
8, 24+68+8+24+24, wndWidth - (8+8), 128,
hWnd, NULL, ghInstance, NULL);
SetWindowFont(gg_lstvCodes, fntMain, TRUE);
SendMessage(gg_lstvCodes, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
// Create the ListView columns.
LV_COLUMN lvCol;
memset(&lvCol, 0, sizeof(lvCol));
lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
// Code
lvCol.pszText = "Code";
lvCol.cx = 128;
SendMessage(gg_lstvCodes, LVM_INSERTCOLUMN, 0, (LPARAM)&lvCol);
// Name
lvCol.pszText = "Name";
lvCol.cx = 256;
SendMessage(gg_lstvCodes, LVM_INSERTCOLUMN, 1, (LPARAM)&lvCol);
// Buttons
const int btnTop = 24+68+8+24+24+128+8;
HWND btnOK, btnApply, btnCancel, btnDeactivateAll, btnDelete;
btnOK = CreateWindow(WC_BUTTON, "&OK", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON,
8, btnTop, 75, 23,
hWnd, (HMENU)IDC_BTN_OK, ghInstance, NULL);
SetWindowFont(btnOK, fntMain, TRUE);
btnApply = CreateWindow(WC_BUTTON, "&Apply", WS_CHILD | WS_VISIBLE | WS_TABSTOP,
8+75+8, btnTop, 75, 23,
hWnd, (HMENU)IDC_BTN_APPLY, ghInstance, NULL);
//.........这里部分代码省略.........
示例2: _WinMain
DWORD WINAPI _WinMain(LPVOID lpParam)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
/*
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
MessageBox(NULL,"AA","AA",MB_OK);
*/
wincl.cbSize = sizeof(wincl); // size of structure
wincl.style = CS_HREDRAW |
CS_VREDRAW; // redraw if size changes
wincl.lpfnWndProc = WndProc; // points to window procedure
wincl.cbClsExtra = 0; // no extra class memory
wincl.cbWndExtra = 0; // no extra window memory
wincl.hInstance = _hinst; // handle to instance
wincl.hIcon = LoadIcon(NULL,
IDI_APPLICATION); // predefined app. icon
wincl.hCursor = LoadCursor(NULL,
IDC_ARROW); // predefined arrow
wincl.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
// wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; // white background brush
wincl.lpszMenuName = "MainMenu"; // name of menu resource
wincl.lpszClassName = "MainWClass"; // name of window class
wincl.hIconSm = NULL;
char buf[100];
//sprintf(buf,"%d",_hinst);
// MessageBox(NULL,buf,"11",MB_OK);
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName, /* Classname */
"MainWClass", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
// CW_USEDEFAULT, /* Windows decides the position */
// CW_USEDEFAULT, /* where the window ends up on the screen */
0,
0,
640, /* The programs width */
400, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
_hinst, /* Program Instance handler */
NULL /* No Window Creation data */
);
if(!hwnd)
{
long lError;
lError = ::GetLastError();
sprintf(buf,"%d, %d",hwnd,lError);
MessageBox(NULL,buf,"22",MB_OK);
return 0;
}
_hwnd=hwnd;
/* Make the window visible on the screen */
ShowWindow (hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
示例3: wf_post_connect
boolean wf_post_connect(freerdp* instance)
{
rdpGdi* gdi;
wfInfo* wfi;
rdpCache* cache;
wfContext* context;
int width, height;
wchar_t win_title[64];
rdpSettings* settings;
settings = instance->settings;
context = (wfContext*) instance->context;
cache = instance->context->cache;
wfi = context->wfi;
wfi->dstBpp = 32;
width = settings->width;
height = settings->height;
if (wfi->sw_gdi)
{
gdi_init(instance, CLRCONV_ALPHA | CLRBUF_32BPP, NULL);
gdi = instance->context->gdi;
wfi->hdc = gdi->primary->hdc;
wfi->primary = wf_image_new(wfi, width, height, wfi->dstBpp, gdi->primary_buffer);
}
else
{
wf_gdi_register_update_callbacks(instance->update);
wfi->srcBpp = instance->settings->color_depth;
wfi->primary = wf_image_new(wfi, width, height, wfi->dstBpp, NULL);
wfi->hdc = gdi_GetDC();
wfi->hdc->bitsPerPixel = wfi->dstBpp;
wfi->hdc->bytesPerPixel = wfi->dstBpp / 8;
wfi->hdc->alpha = wfi->clrconv->alpha;
wfi->hdc->invert = wfi->clrconv->invert;
wfi->hdc->hwnd = (HGDI_WND) malloc(sizeof(GDI_WND));
wfi->hdc->hwnd->invalid = gdi_CreateRectRgn(0, 0, 0, 0);
wfi->hdc->hwnd->invalid->null = 1;
wfi->hdc->hwnd->count = 32;
wfi->hdc->hwnd->cinvalid = (HGDI_RGN) malloc(sizeof(GDI_RGN) * wfi->hdc->hwnd->count);
wfi->hdc->hwnd->ninvalid = 0;
}
if (strlen(wfi->window_title) > 0)
_snwprintf(win_title, sizeof(win_title), L"%S", wfi->window_title);
else if (settings->port == 3389)
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"%S - FreeRDP", settings->hostname);
else
_snwprintf(win_title, sizeof(win_title) / sizeof(win_title[0]), L"%S:%d - FreeRDP", settings->hostname, settings->port);
if (wfi->hwnd == 0)
{
wfi->hwnd = CreateWindowEx((DWORD) NULL, g_wnd_class_name, win_title,
0, 0, 0, 0, 0, NULL, NULL, g_hInstance, NULL);
SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, (LONG_PTR) wfi);
}
if (wfi->fullscreen)
{
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_POPUP);
SetWindowPos(wfi->hwnd, HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
}
else
{
POINT diff;
RECT rc_client, rc_wnd;
SetWindowLongPtr(wfi->hwnd, GWL_STYLE, WS_CAPTION | WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX);
/* Now resize to get full canvas size and room for caption and borders */
SetWindowPos(wfi->hwnd, HWND_TOP, 10, 10, width, height, SWP_FRAMECHANGED);
GetClientRect(wfi->hwnd, &rc_client);
GetWindowRect(wfi->hwnd, &rc_wnd);
diff.x = (rc_wnd.right - rc_wnd.left) - rc_client.right;
diff.y = (rc_wnd.bottom - rc_wnd.top) - rc_client.bottom;
SetWindowPos(wfi->hwnd, HWND_TOP, -1, -1, width + diff.x, height + diff.y, SWP_NOMOVE | SWP_FRAMECHANGED);
}
BitBlt(wfi->primary->hdc, 0, 0, width, height, NULL, 0, 0, BLACKNESS);
wfi->drawing = wfi->primary;
ShowWindow(wfi->hwnd, SW_SHOWNORMAL);
UpdateWindow(wfi->hwnd);
if (wfi->sw_gdi)
{
instance->update->BeginPaint = wf_sw_begin_paint;
instance->update->EndPaint = wf_sw_end_paint;
}
else
{
instance->update->BeginPaint = wf_hw_begin_paint;
instance->update->EndPaint = wf_hw_end_paint;
}
//.........这里部分代码省略.........
示例4: m_bFullScreen
/* This Code Creates Our OpenGL Window. Parameters Are:
* lpszTitle - Title to Appear at the Top of the Window
* hWndParent - Parent HWND where the screne will be drawn
* nZBuffer - Number of Bits to Use for Z-Buffer (16/32)
*/
bool CGL::Create(char* lpszTitle, HWND hWndParent, int nZBuffer=16) : m_bFullScreen(false)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT rectWindow; // Grabs Rectangle Upper Left / Lower Right Values
int nWidth,
nHeight;
// Get window size
GetClientRect(hWndParent, &rectWindow);
nWidth = rectWindow.right-rectWindow.left;
nHeight = rectWindow.bottom-rectWindow.top;
m_hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = m_hInstance; // Set The Instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
wc.hbrBackground = NULL; // No Background Required For GL
wc.lpszMenuName = NULL; // We Don't Want A Menu
wc.lpszClassName = "OpenGL"; // Set The Class Name
if (!RegisterClass(&wc)) // Attempt To Register The Window Class
{
MessageBox(m_hWnd,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
//dwStyle = WS_OVERLAPPEDWINDOW; // Windows Style
dwStyle = WS_DISABLED | WS_VISIBLE | WS_CHILD; // Windows Style
AdjustWindowRectEx(&rectWindow, dwStyle, false, dwExStyle); // Adjust Window To true Requested Size
// Create The Window
if (!(m_hWnd=CreateWindowEx(dwExStyle, // Extended Style For The Window
"OpenGL", // Class Name
lpszTitle, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
m_hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
nBits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
nZBuffer, // 16/32Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(m_hDC=GetDC(m_hWnd))) // Did We Get A Device Context?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
if (!(PixelFormat=ChoosePixelFormat(m_hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(m_hWnd,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false; // Return false
}
//.........这里部分代码省略.........
示例5: WndProc
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
RECT rect;
COLORREF colorText = RGB(0, 0, 255); // задаём цвет текста
switch (message)
{
case WM_COMMAND:
case BN_CLICKED:
if (LOWORD(wParam) == ID_BUTTON1)
{
GetClientRect(hWnd, &rect);
edit1 = CreateWindowEx(
WS_EX_CLIENTEDGE,
L"edit",
L"Нажмите правую клавишу мыши",
WS_CHILD | WS_VISIBLE | EM_FMTLINES,
rect.right / 4, /*координаты по X*/
rect.bottom / 4, /*координаты по Y*/
rect.right / 2, /*Ширина окошка*/
rect.bottom / 2,
hWnd,
(HMENU)ID_EDIT1,
hinst,
NULL);
}
break;
case WM_RBUTTONDOWN:
ShowWindow(edit1, SW_HIDE);
break;
case WM_CREATE:
GetClientRect(hWnd, &rect);
button1 = CreateWindowEx(
WS_EX_CLIENTEDGE,
L"button",
L"Показать",
WS_CHILD | WS_VISIBLE,
rect.right / 2 - ARRAYSIZE(L"Показать") * 4 - 10, /*координаты по X*/
rect.bottom - 30, /*координаты по Y*/
ARRAYSIZE(L"Показать") * 10, /*Ширина окошка*/
25,
hWnd,
(HMENU)ID_BUTTON1,
hinst,
NULL);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps); // инициализируем контекст устройства
GetClientRect(hWnd, &rect); // получаем ширину и высоту области для рисования
SetTextColor(hdc, colorText); // устанавливаем цвет контекстного устройства
DrawText(hdc, L"В в е д и т е т е к с т", -1, &rect, DT_SINGLELINE | DT_CENTER); // рисуем текст
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return 0;
}
示例6: switch
INT_PTR SettingsVideo::ProcMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwndTemp;
switch(message)
{
case WM_INITDIALOG:
{
LocalizeWindow(hwnd);
//--------------------------------------------
HWND hwndToolTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, NULL, hinstMain, NULL);
TOOLINFO ti;
zero(&ti, sizeof(ti));
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
ti.hwnd = hwnd;
SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, 500);
SendMessage(hwndToolTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 8000);
//--------------------------------------------
hwndTemp = GetDlgItem(hwnd, IDC_MONITOR);
App->monitors.Clear();
EnumDisplayMonitors(NULL, NULL, (MONITORENUMPROC)MonitorInfoEnumProc, (LPARAM)&App->monitors);
for(UINT i=0; i<App->monitors.Num(); i++)
SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)IntString(i+1).Array());
int monitorID = LoadSettingComboInt(hwndTemp, TEXT("Video"), TEXT("Monitor"), 0, App->monitors.Num()-1);
if(monitorID > (int)App->monitors.Num())
monitorID = 0;
//--------------------------------------------
SendMessage(GetDlgItem(hwnd, IDC_USECUSTOM), BM_SETCHECK, BST_CHECKED, 0);
EnableWindow(GetDlgItem(hwnd, IDC_MONITOR), FALSE);
//--------------------------------------------
int cx, cy;
if(!AppConfig->HasKey(TEXT("Video"), TEXT("BaseWidth")) || !AppConfig->HasKey(TEXT("Video"), TEXT("BaseHeight")))
{
cx = App->monitors[monitorID].rect.right - App->monitors[monitorID].rect.left;
cy = App->monitors[monitorID].rect.bottom - App->monitors[monitorID].rect.top;
AppConfig->SetInt(TEXT("Video"), TEXT("BaseWidth"), cx);
AppConfig->SetInt(TEXT("Video"), TEXT("BaseHeight"), cy);
}
else
{
cx = AppConfig->GetInt(TEXT("Video"), TEXT("BaseWidth"));
cy = AppConfig->GetInt(TEXT("Video"), TEXT("BaseHeight"));
if(cx < 128) cx = 128;
else if(cx > 4096) cx = 4096;
if(cy < 128) cy = 128;
else if(cy > 4096) cy = 4096;
}
hwndTemp = GetDlgItem(hwnd, IDC_SIZEX);
editProc = (FARPROC)GetWindowLongPtr(hwndTemp, GWLP_WNDPROC);
SetWindowLongPtr(hwndTemp, GWLP_WNDPROC, (LONG_PTR)ResolutionEditSubclassProc);
SetWindowText(hwndTemp, IntString(cx).Array());
hwndTemp = GetDlgItem(hwnd, IDC_SIZEY);
SetWindowLongPtr(hwndTemp, GWLP_WNDPROC, (LONG_PTR)ResolutionEditSubclassProc);
SetWindowText(hwndTemp, IntString(cy).Array());
//--------------------------------------------
hwndTemp = GetDlgItem(hwnd, IDC_DISABLEAERO);
if(OSGetVersion() == 8)
EnableWindow(hwndTemp, FALSE);
BOOL bDisableAero = AppConfig->GetInt(TEXT("Video"), TEXT("DisableAero"), 0);
SendMessage(hwndTemp, BM_SETCHECK, bDisableAero ? BST_CHECKED : 0, 0);
ti.lpszText = (LPWSTR)Str("Settings.Video.DisableAeroTooltip");
ti.uId = (UINT_PTR)hwndTemp;
SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
//--------------------------------------------
BOOL bUnlockFPS = AppConfig->GetInt(TEXT("Video"), TEXT("UnlockFPS"));
int topFPS = bUnlockFPS ? 120 : 60;
hwndTemp = GetDlgItem(hwnd, IDC_FPS);
SendMessage(hwndTemp, UDM_SETRANGE32, 10, topFPS);
int fps = AppConfig->GetInt(TEXT("Video"), TEXT("FPS"), 30);
if(!AppConfig->HasKey(TEXT("Video"), TEXT("FPS")))
{
//.........这里部分代码省略.........
示例7: WinMain
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char const * class_name = "Pong";
char const * window_title = "Adolf Hitler Pong";
WNDCLASSEX window_class;
window_class.cbSize = sizeof(window_class);
window_class.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
window_class.lpfnWndProc = &window_procedure;
window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0;
window_class.hInstance = hInstance;
window_class.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HITLER));
window_class.hCursor = LoadCursor(0, IDC_ARROW);
window_class.hbrBackground = reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
window_class.lpszMenuName = 0;
window_class.lpszClassName = class_name;
window_class.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HITLER));
RegisterClassEx(&window_class);
HWND window_handle = CreateWindowEx(0, class_name, window_title, WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, window_width, window_height, 0, 0, hInstance, 0);
//SetTimer(window_handle, 0, 1000 / fps, 0);
std::string arguments(lpCmdLine);
if(!arguments.empty())
{
if(arguments[0] == '"' && arguments.length() >= 2)
{
arguments.erase(arguments.begin());
arguments.erase(arguments.end() - 1);
}
bool success = game.load_demo(arguments);
if(!success)
{
MessageBox(window_handle, "Unable to load demo file", "Demo playback error", MB_OK | MB_ICONERROR);
SendMessage(window_handle, WM_DESTROY, 0, 0);
return 0;
}
}
else
game.start_game();
nil::ini ini;
if(ini.load("pong.ini"))
{
game.set_demo_level_limit(ini.number<unsigned>("demo_level_limit", 3));
SetThreadPriority(GetCurrentThread(), ini.number<int>("thread_priority", 0));
}
LARGE_INTEGER frequency_struct;
QueryPerformanceFrequency(&frequency_struct);
unsigned long long divisor = frequency_struct.QuadPart / fps;
unsigned long long last_state = 0ull;
while(run)
{
MSG message;
while(PeekMessage(&message, window_handle, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
unsigned long long current_state = counter.QuadPart / divisor;
if(last_state < current_state)
{
game.invalidate(window_handle);
game.process_frame(window_handle);
last_state = current_state;
}
//Sleep(20);
}
return 0;
}
示例8: CreateWindowGL
BOOL CreateWindowGL (GL_Window* window) // This Code Creates Our OpenGL Window
{
DWORD windowStyle = WS_OVERLAPPEDWINDOW; // Define Our Window Style
DWORD windowExtendedStyle = WS_EX_APPWINDOW; // Define The Window's Extended Style
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
window->init.bitsPerPixel, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
RECT windowRect = {0, 0, window->init.width, window->init.height}; // Define Our Window Coordinates
GLuint PixelFormat; // Will Hold The Selected Pixel Format
if (window->init.isFullScreen == TRUE) // Fullscreen Requested, Try Changing Video Modes
{
if (ChangeScreenResolution (window->init.width, window->init.height, window->init.bitsPerPixel) == FALSE)
{
// Fullscreen Mode Failed. Run In Windowed Mode Instead
MessageBox (HWND_DESKTOP, "Mode Switch Failed.\nRunning In Windowed Mode.", "Error", MB_OK | MB_ICONEXCLAMATION);
window->init.isFullScreen = FALSE; // Set isFullscreen To False (Windowed Mode)
}
else // Otherwise (If Fullscreen Mode Was Successful)
{
ShowCursor (FALSE); // Turn Off The Cursor
windowStyle = WS_POPUP; // Set The WindowStyle To WS_POPUP (Popup Window)
windowExtendedStyle |= WS_EX_TOPMOST; // Set The Extended Window Style To WS_EX_TOPMOST
} // (Top Window Covering Everything Else)
}
else // If Fullscreen Was Not Selected
{
// Adjust Window, Account For Window Borders
AdjustWindowRectEx (&windowRect, windowStyle, 0, windowExtendedStyle);
}
// Create The OpenGL Window
window->hWnd = CreateWindowEx (windowExtendedStyle, // Extended Style
window->init.application->className, // Class Name
window->init.title, // Window Title
windowStyle, // Window Style
0, 0, // Window X,Y Position
windowRect.right - windowRect.left, // Window Width
windowRect.bottom - windowRect.top, // Window Height
HWND_DESKTOP, // Desktop Is Window's Parent
0, // No Menu
window->init.application->hInstance, // Pass The Window Instance
window);
if (window->hWnd == 0) // Was Window Creation A Success?
{
return FALSE; // If Not Return False
}
window->hDC = GetDC (window->hWnd); // Grab A Device Context For This Window
if (window->hDC == 0) // Did We Get A Device Context?
{
// Failed
DestroyWindow (window->hWnd); // Destroy The Window
window->hWnd = 0; // Zero The Window Handle
return FALSE; // Return False
}
PixelFormat = ChoosePixelFormat (window->hDC, &pfd); // Find A Compatible Pixel Format
if (PixelFormat == 0) // Did We Find A Compatible Format?
{
// Failed
ReleaseDC (window->hWnd, window->hDC); // Release Our Device Context
window->hDC = 0; // Zero The Device Context
DestroyWindow (window->hWnd); // Destroy The Window
window->hWnd = 0; // Zero The Window Handle
return FALSE; // Return False
}
if (SetPixelFormat (window->hDC, PixelFormat, &pfd) == FALSE) // Try To Set The Pixel Format
{
// Failed
ReleaseDC (window->hWnd, window->hDC); // Release Our Device Context
window->hDC = 0; // Zero The Device Context
DestroyWindow (window->hWnd); // Destroy The Window
window->hWnd = 0; // Zero The Window Handle
return FALSE; // Return False
}
//.........这里部分代码省略.........
示例9: GetModuleHandle
void SystemClass::InitializeWindows(int& screenWidth, int& screenHeight)
{
WNDCLASSEX wc;
DEVMODE dmScreenSettings;
int posX, posY;
// Get an external pointer to this object.
ApplicationHandle = this;
// Get the instance of this application.
m_hinstance = GetModuleHandle(NULL);
// Give the application a name.
m_applicationName = L"Engine";
// Setup the windows class with default settings.
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = m_hinstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hIconSm = wc.hIcon;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = m_applicationName;
wc.cbSize = sizeof(WNDCLASSEX);
// Register the window class.
RegisterClassEx(&wc);
// Determine the resolution of the clients desktop screen.
screenWidth = GetSystemMetrics(SM_CXSCREEN);
screenHeight = GetSystemMetrics(SM_CYSCREEN);
// Setup the screen settings depending on whether it is running in full screen or in windowed mode.
if(FULL_SCREEN)
{
// If full screen set the screen to maximum size of the users desktop and 32bit.
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = (unsigned long)screenWidth;
dmScreenSettings.dmPelsHeight = (unsigned long)screenHeight;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
// Change the display settings to full screen.
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
// Set the position of the window to the top left corner.
posX = posY = 0;
}
else
{
// If windowed then set it to 800x600 resolution.
screenWidth = 800;
screenHeight = 600;
// Place the window in the middle of the screen.
posX = (GetSystemMetrics(SM_CXSCREEN) - screenWidth) / 2;
posY = (GetSystemMetrics(SM_CYSCREEN) - screenHeight) / 2;
}
// Create the window with the screen settings and get the handle to it.
m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP,
posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL);
// Bring the window up on the screen and set it as main focus.
ShowWindow(m_hwnd, SW_SHOW);
SetForegroundWindow(m_hwnd);
SetFocus(m_hwnd);
// Hide the mouse cursor.
ShowCursor(false);
return;
}
示例10: memset
//************************************
// Method: CreateWindow
// FullName: QuackWin::CreateWindow
// Access: public
// Returns: bool
// Qualifier:
// Parameter: int width
// Parameter: int height
// Parameter: int colorBits
//************************************
bool QuackWin::B_CreateWindow(int width, int height, int colorBits) {
if (!classRegistered) {
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)wndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(void*)+sizeof(int);
wc.hInstance = GetModuleHandle(NULL);
//wc.hIcon = LoadIcon(hinstOpenGL, MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClass(&wc)) {
// TODO: Add safe error here
// unable to register class
}
classRegistered = true;
}
// create HWND
if (!hWnd) {
hWnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
WINDOW_CLASS_NAME,
"Quack",
WS_VISIBLE | WS_OVERLAPPEDWINDOW,
0,
0,
width,
height,
NULL,
NULL,
hinstOpenGL,
this
);
if (!hWnd) {
// error creating the window
}
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
}
if (!(hDC = GetDC(hWnd))) {
ShowWindow(hWnd, SW_HIDE);
DestroyWindow(hWnd);
hWnd = NULL;
return false;
}
// Create OpenGL Context
if (!MakeContext()) {
ShowWindow(hWnd, SW_HIDE);
DestroyWindow(hWnd);
hWnd = NULL;
return false;
}
SetForegroundWindow(hWnd);
SetFocus(hWnd);
return true;
}
示例11: InitGLCapture
bool InitGLCapture()
{
static HWND hwndOpenGLSetupWindow = NULL;
bool bSuccess = false;
if(!hwndOpenGLSetupWindow)
{
WNDCLASSEX windowClass;
ZeroMemory(&windowClass, sizeof(windowClass));
windowClass.cbSize = sizeof(windowClass);
windowClass.style = CS_OWNDC;
windowClass.lpfnWndProc = DefWindowProc;
windowClass.lpszClassName = TEXT("OBSOGLHookClass");
windowClass.hInstance = hinstMain;
if(RegisterClassEx(&windowClass))
{
hwndOpenGLSetupWindow = CreateWindowEx (0,
TEXT("OBSOGLHookClass"),
TEXT("OBS OpenGL Context Window"),
WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0,
1, 1,
NULL,
NULL,
hinstMain,
NULL
);
}
}
HMODULE hGL = GetModuleHandle(TEXT("opengl32.dll"));
if(hGL && hwndOpenGLSetupWindow)
{
pglReadBuffer = (GLREADBUFFERPROC) GetProcAddress(hGL, "glReadBuffer");
pglReadPixels = (GLREADPIXELSPROC) GetProcAddress(hGL, "glReadPixels");
pglGetError = (GLGETERRORPROC) GetProcAddress(hGL, "glGetError");
pwglSwapLayerBuffers= (WGLSWAPLAYERBUFFERSPROC) GetProcAddress(hGL, "wglSwapLayerBuffers");
pwglSwapBuffers= (WGLSWAPBUFFERSPROC) GetProcAddress(hGL, "wglSwapBuffers");
pwglDeleteContext = (WGLDELETECONTEXTPROC) GetProcAddress(hGL, "wglDeleteContext");
pwglGetProcAddress = (WGLGETPROCADDRESSPROC) GetProcAddress(hGL, "wglGetProcAddress");
pwglMakeCurrent = (WGLMAKECURRENTPROC) GetProcAddress(hGL, "wglMakeCurrent");
pwglCreateContext = (WGLCREATECONTEXTPROC) GetProcAddress(hGL, "wglCreateContext");
if( !pglReadBuffer || !pglReadPixels || !pglGetError || !pwglSwapLayerBuffers || !pwglSwapBuffers ||
!pwglDeleteContext || !pwglGetProcAddress || !pwglMakeCurrent || !pwglCreateContext)
{
return false;
}
HDC hDC = GetDC(hwndOpenGLSetupWindow);
if(hDC)
{
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 32;
pfd.cAccumBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd);
HGLRC hGlrc = jimglCreateContext(hDC);
if(hGlrc)
{
jimglMakeCurrent(hDC, hGlrc);
pglBufferData = (GLBUFFERDATAARBPROC) jimglGetProcAddress("glBufferData");
pglDeleteBuffers = (GLDELETEBUFFERSARBPROC) jimglGetProcAddress("glDeleteBuffers");
pglGenBuffers = (GLGENBUFFERSARBPROC) jimglGetProcAddress("glGenBuffers");
pglMapBuffer = (GLMAPBUFFERPROC) jimglGetProcAddress("glMapBuffer");
pglUnmapBuffer = (GLUNMAPBUFFERPROC) jimglGetProcAddress("glUnmapBuffer");
pglBindBuffer = (GLBINDBUFFERPROC) jimglGetProcAddress("glBindBuffer");
UINT lastErr = GetLastError();
if(pglBufferData && pglDeleteBuffers && pglGenBuffers && pglMapBuffer && pglUnmapBuffer && pglBindBuffer)
{
glHookSwapBuffers.Hook((FARPROC)SwapBuffers, (FARPROC)SwapBuffersHook);
glHookSwapLayerBuffers.Hook((FARPROC)jimglSwapLayerBuffers, (FARPROC)wglSwapLayerBuffersHook);
glHookwglSwapBuffers.Hook((FARPROC)jimglSwapBuffers, (FARPROC)wglSwapBuffersHook);
glHookDeleteContext.Hook((FARPROC)jimglDeleteContext, (FARPROC)wglDeleteContextHook);
bSuccess = true;
}
jimglMakeCurrent(NULL, NULL);
jimglDeleteContext(hGlrc);
ReleaseDC(hwndOpenGLSetupWindow, hDC);
if(bSuccess)
{
glHookSwapBuffers.Rehook();
glHookSwapLayerBuffers.Rehook();
//.........这里部分代码省略.........
示例12: khm_create_standard_toolbar
void khm_create_standard_toolbar(HWND rebar) {
HWND hwtb;
SIZE sz;
HBITMAP hbm_blank;
HIMAGELIST hiList;
REBARBANDINFO rbi;
khui_menu_def * def;
khui_action * act;
khui_action_ref * aref;
int idx_blank;
def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
if (!def) {
#ifdef DEBUG
assert(FALSE);
#endif
return;
}
hwtb = CreateWindowEx(0 ,
TOOLBARCLASSNAME,
(LPWSTR) NULL,
WS_CHILD |
TBSTYLE_FLAT |
TBSTYLE_AUTOSIZE |
TBSTYLE_TOOLTIPS |
CCS_NORESIZE |
CCS_NOPARENTALIGN |
CCS_ADJUSTABLE |
CCS_NODIVIDER,
0, 0, 0, 0, rebar,
(HMENU) NULL, khm_hInstance,
NULL);
if(!hwtb) {
#ifdef DEBUG
assert(FALSE);
#endif
return;
}
#if (_WIN32_IE >= 0x0501)
SendMessage(hwtb, TB_SETEXTENDEDSTYLE, 0,
TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DRAWDDARROWS);
#endif
hiList = ImageList_Create(
KHUI_TOOLBAR_IMAGE_WIDTH,
KHUI_TOOLBAR_IMAGE_HEIGHT,
ILC_MASK,
(int) khui_action_list_length(def->items),
3);
hbm_blank = LoadImage(khm_hInstance,
MAKEINTRESOURCE(IDB_TB_BLANK),
IMAGE_BITMAP,
KHUI_TOOLBAR_IMAGE_WIDTH,
KHUI_TOOLBAR_IMAGE_HEIGHT, 0);
idx_blank = ImageList_AddMasked(hiList, hbm_blank, RGB(0,0,0));
khui_hwnd_standard_toolbar = hwtb;
khui_tb_blank = idx_blank;
def = khui_find_menu(KHUI_TOOLBAR_STANDARD);
aref = def->items;
SendMessage(hwtb,
TB_BUTTONSTRUCTSIZE,
sizeof(TBBUTTON),
0);
SendMessage(hwtb,
TB_SETBITMAPSIZE,
0,
MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));
SendMessage(hwtb,
TB_SETIMAGELIST,
0,
(LPARAM) hiList);
SendMessage(hwtb,
TB_SETBUTTONSIZE,
0,
MAKELONG(KHUI_TOOLBAR_IMAGE_WIDTH,KHUI_TOOLBAR_IMAGE_HEIGHT));
while(aref && aref->action != KHUI_MENU_END) {
if(aref->action == KHUI_MENU_SEP) {
khui_add_action_to_toolbar(hwtb,
NULL,
KHUI_TOOLBAR_ADD_SEP,
hiList);
} else {
act = khui_find_action(aref->action);
khui_add_action_to_toolbar(hwtb,
act,
KHUI_TOOLBAR_ADD_BITMAP |
((aref->flags & KHUI_ACTIONREF_SUBMENU)?
//.........这里部分代码省略.........
示例13: DialogBox
bool WINDOW::InitExtended()
{
//Put up dialog box and find out which number of samples to use
DialogBox(hInstance, MAKEINTRESOURCE(IDD_RESOLUTION), HWND_DESKTOP, SelectModeProc);
//Create a rect structure for the size/position of the window
RECT windowRect;
windowRect.left=0;
windowRect.right=(long)width;
windowRect.top=0;
windowRect.bottom=(long)height;
//Window class structure
WNDCLASS wc;
//Fill in window class struct
wc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC; //Style - redraw on move, own DC
wc.lpfnWndProc= (WNDPROC) WndProc; //Wndproc handles messages
wc.cbClsExtra= 0;
wc.cbWndExtra= 0;
wc.hInstance= hInstance; //Handle to instance
wc.hIcon= LoadIcon(NULL, IDI_WINLOGO); //Load windows logo icon
wc.hCursor= LoadCursor(NULL, IDC_ARROW); //Load standard cursor
wc.hbrBackground= NULL; //No background required
wc.lpszMenuName= NULL; //No Menu
wc.lpszClassName= "OpenGL"; //class name
//Register window class
if(!RegisterClass(&wc))
{
LOG::Instance()->OutputError("Unable to register window class");
return false;
}
else
LOG::Instance()->OutputSuccess("Window Class Registered");
//Switch to fullscreen if required
if(fullscreen)
{
DEVMODE screenSettings; //device mode
memset(&screenSettings, 0, sizeof(screenSettings));
screenSettings.dmSize=sizeof(screenSettings);
//Set size & color bits
screenSettings.dmPelsWidth=width;
screenSettings.dmPelsHeight=height;
screenSettings.dmBitsPerPel=redBits+greenBits+blueBits+alphaBits;
screenSettings.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
//Try to change to full screen
if(ChangeDisplaySettings(&screenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
//If failed, ask whether to run in window
char * errorText="The Requested Full Screen Mode Is Not Supported By\n Your Video Card. Use Windowed Mode Instead?";
if(MessageBox(NULL, errorText, title, MB_YESNO | MB_ICONEXCLAMATION)==IDYES)
fullscreen=false;
else
{
LOG::Instance()->OutputError("Requested full screen mode not supported, quitting...");
return false;
}
}
}
//Set window style & extended style
DWORD style, exStyle;
if(fullscreen)
{
exStyle=WS_EX_APPWINDOW;
style=WS_POPUP | WS_VISIBLE; //no border
//Hide cursor
ShowCursor(false);
}
else
{
exStyle=WS_EX_CLIENTEDGE;
style=WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_VISIBLE;
}
//Adjust the window size so that client area is the size requested
AdjustWindowRectEx(&windowRect, style, false, exStyle);
//Create Window
if(!(hWnd=CreateWindowEx( exStyle, //window style
"OpenGL", //class name
title,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, //style
0, 0, //position
windowRect.right-windowRect.left, //width
windowRect.bottom-windowRect.top, //height
NULL, NULL,
hInstance,
//.........这里部分代码省略.........
示例14: CreateHypCtrl
//.........这里部分代码省略.........
GetObject(hFontParent, sizeof(LOGFONT), &lf);
switch (pHcWnd->ulStyle) {
case ulHover:
hFontNormal = CreateFontIndirect(&lf);
lf.lfUnderline = (BYTE) TRUE;
hFontHover = CreateFontIndirect(&lf);
break;
case ulAlways:
lf.lfUnderline = (BYTE) TRUE;
hFontNormal = CreateFontIndirect(&lf);
hFontHover = CreateFontIndirect(&lf);
break;
case ulNone:
hFontNormal = CreateFontIndirect(&lf);
hFontHover = CreateFontIndirect(&lf);
break;
}
// save the fonts in the window extra space
SetWindowLong(hWndHyperlink, WND_FONTN, (LONG) hFontNormal);
SetWindowLong(hWndHyperlink, WND_FONTH, (LONG) hFontHover);
} else {
// use the system font
SetWindowLong(hWndHyperlink, WND_FONTN, (LONG) NULL);
SetWindowLong(hWndHyperlink, WND_FONTH, (LONG) NULL);
}
GetClientRect(hWndHyperlink, &rect);
// adjust window size to fit the text
if (pHcWnd->bAutoSize) {
PAINTSTRUCT ps;
HDC hdc;
SIZE size;
hdc = BeginPaint(hWndHyperlink, &ps);
SelectObject(hdc, (HFONT) GetWindowLong(hWndHyperlink, WND_FONTN));
GetTextExtentPoint32(hdc, pHcWnd->szText, GetStringLength(pHcWnd->szText), &size);
rect.right = size.cx - rect.left;
rect.bottom = size.cy - rect.top;
EndPaint(hWndHyperlink, &ps);
SetWindowPos(hWndHyperlink,
0,
0, 0, size.cx, size.cy,
SWP_NOMOVE | SWP_NOZORDER);
}
// save window size in the window extra space
SetWindowLong(hWndHyperlink, WND_LEFT, (LONG) (rect.left));
SetWindowLong(hWndHyperlink, WND_TOP, (LONG) (rect.top));
SetWindowLong(hWndHyperlink, WND_RIGHT, (LONG) (rect.right));
SetWindowLong(hWndHyperlink, WND_BOTTOM, (LONG) (rect.bottom));
// create tooltip if requested
if (pHcWnd->szTooltip != NULL) {
HWND hWndTT;
TOOLINFO ti;
hWndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hWndHyperlink,
NULL,
hInst,
NULL);
if (!hWndTT) return FALSE;
SetWindowPos(hWndTT,
HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hWndHyperlink;
ti.hinst = hInst;
ti.uId = 0;
ti.lpszText = pHcWnd->szTooltip; // get text for tooltip
ti.rect.left = (LONG) GetWindowLong(hWndHyperlink, WND_LEFT);
ti.rect.top = (LONG) GetWindowLong(hWndHyperlink, WND_TOP);
ti.rect.right = (LONG) GetWindowLong(hWndHyperlink, WND_RIGHT);
ti.rect.bottom = (LONG) GetWindowLong(hWndHyperlink, WND_BOTTOM);
// add tooltip
SendMessage(hWndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
}
// show the window
ShowWindow(hWndHyperlink, SW_NORMAL);
UpdateWindow(hWndHyperlink);
return hWndHyperlink;
}
示例15: VID_CreateWindow
qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
{
#ifdef __WXWINDOWS__
glw_state.hWnd = *(HWND*) ri.Vid_GetWindowPtr();
#else
WNDCLASS wc;
RECT r;
cvar_t *vid_xpos, *vid_ypos;
int stylebits;
int x, y, w, h;
int exstyle;
/* Register the frame class */
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)glw_state.wndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = glw_state.hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = (void *)COLOR_GRAYTEXT;
wc.lpszMenuName = 0;
wc.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClass (&wc) )
ri.Sys_Error (ERR_FATAL, "Couldn't register window class");
if (fullscreen)
{
exstyle = WS_EX_TOPMOST;
stylebits = WS_POPUP|WS_VISIBLE;
}
else
{
exstyle = 0;
stylebits = WINDOW_STYLE;
}
r.left = 0;
r.top = 0;
r.right = width;
r.bottom = height;
AdjustWindowRect (&r, stylebits, FALSE);
w = r.right - r.left;
h = r.bottom - r.top;
if (fullscreen)
{
x = 0;
y = 0;
}
else
{
vid_xpos = ri.Cvar_Get ("vid_xpos", "0", 0);
vid_ypos = ri.Cvar_Get ("vid_ypos", "0", 0);
x = vid_xpos->value;
y = vid_ypos->value;
}
glw_state.hWnd = CreateWindowEx (
exstyle,
WINDOW_CLASS_NAME,
"Quake 2",
stylebits,
x, y, w, h,
NULL,
NULL,
glw_state.hInstance,
NULL);
#endif // ndef __WXWINDOWS__
if (!glw_state.hWnd)
ri.Sys_Error (ERR_FATAL, "Couldn't create window");
ShowWindow( glw_state.hWnd, SW_SHOW );
UpdateWindow( glw_state.hWnd );
// init all the gl stuff for the window
if (!GLimp_InitGL ())
{
ri.Con_Printf( PRINT_ALL, "VID_CreateWindow() - GLimp_InitGL failed\n");
return false;
}
SetForegroundWindow( glw_state.hWnd );
SetFocus( glw_state.hWnd );
// let the sound and input subsystems know about the new window
ri.Vid_NewWindow (width, height);
return true;
}