int GAcreatewidget ( Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp ) { PIXsize_t ps; DWORD wflags; int mode, ai; if (!parent) { Gerr (POS, G_ERRNOPARENTWIDGET); return -1; } wflags = WS_CHILDWINDOW; mode = G_AWVARRAY; WAU->func = NULL; ps.x = ps.y = MINAWSIZE; for (ai = 0; ai < attrn; ai++) { switch (attrp[ai].id) { case G_ATTRSIZE: GETSIZE (attrp[ai].u.s, ps, MINAWSIZE); break; case G_ATTRBORDERWIDTH: wflags |= WS_BORDER; break; case G_ATTRMODE: if (strcmp ("horizontal", attrp[ai].u.t) == 0) mode = G_AWHARRAY; else if (strcmp ("vertical", attrp[ai].u.t) == 0) mode = G_AWVARRAY; else { Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t); return -1; } break; case G_ATTRLAYOUT: if (strcmp ("on", attrp[ai].u.t) == 0) { Gawsetmode (widget, FALSE); WAU->mode = G_AWHARRAY; } else if (strcmp ("off", attrp[ai].u.t) == 0) { Gawsetmode (widget, TRUE); WAU->mode = G_AWHARRAY; } else { Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t); return -1; } break; case G_ATTRWINDOWID: Gerr (POS, G_ERRCANNOTSETATTR1, "windowid"); return -1; case G_ATTRRESIZECB: WAU->func = attrp[ai].u.func; break; case G_ATTRUSERDATA: widget->udata = attrp[ai].u.u; break; default: Gerr (POS, G_ERRBADATTRID, attrp[ai].id); return -1; } } Gawinitialize (widget, mode); Gadjustwrect (parent, &ps); if (!(widget->w = CreateWindow ( "ArrayClass", "array", wflags, 0, 0, ps.x, ps.y, parent->w, (HMENU) (widget - &Gwidgets[0]), hinstance, NULL ))) { Gerr (POS, G_ERRCANNOTCREATEWIDGET); return -1; } ShowWindow (widget->w, SW_SHOW); UpdateWindow (widget->w); if (parent && parent->type == G_ARRAYWIDGET) Gawinsertchild (parent, widget); return 0; }
static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { int iUser; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { int iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)TranslateT("<All connections>")); SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, (LPARAM)-1); SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETCURSEL, iItem, 0); { mir_cslock lck(csNetlibUser); for (int i = 0; i < netlibUser.getCount(); ++i) { NetlibTempSettings *thisSettings = (NetlibTempSettings*)mir_calloc(sizeof(NetlibTempSettings)); thisSettings->flags = netlibUser[i]->user.flags; thisSettings->szSettingsModule = mir_strdup(netlibUser[i]->user.szSettingsModule); CopySettingsStruct(&thisSettings->settings, &netlibUser[i]->settings); tempSettings.insert(thisSettings); if (netlibUser[i]->user.flags & NUF_NOOPTIONS) continue; iItem = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_ADDSTRING, 0, (LPARAM)netlibUser[i]->user.ptszDescriptiveName); SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_SETITEMDATA, iItem, i); } } } SendMessage(hwndDlg, M_REFRESHALL, 0, 0); return TRUE; case M_REFRESHALL: iUser = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_GETCURSEL, 0, 0), 0); { NETLIBUSERSETTINGS settings = { 0 }; DWORD flags = 0; if (iUser == -1) { settings.cbSize = sizeof(settings); for (int i = 0; i < tempSettings.getCount(); i++) { NetlibTempSettings *p = tempSettings[i]; if (!(p->flags & NUF_NOOPTIONS)) CombineSettingsStructs(&settings, &flags, &p->settings, p->flags); } } else { NetlibFreeUserSettingsStruct(&settings); CopySettingsStruct(&settings, &tempSettings[iUser]->settings); flags = tempSettings[iUser]->flags; } ShowMultipleControls(hwndDlg, outgoingConnectionsControls, _countof(outgoingConnectionsControls), flags&NUF_OUTGOING ? SW_SHOW : SW_HIDE); CheckDlgButton(hwndDlg, IDC_USEPROXY, settings.useProxy ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_RESETCONTENT, 0, 0); if (settings.proxyType == 0) AddProxyTypeItem(hwndDlg, 0, settings.proxyType); AddProxyTypeItem(hwndDlg, PROXYTYPE_SOCKS4, settings.proxyType); AddProxyTypeItem(hwndDlg, PROXYTYPE_SOCKS5, settings.proxyType); if (flags & (NUF_HTTPCONNS | NUF_HTTPGATEWAY)) AddProxyTypeItem(hwndDlg, PROXYTYPE_HTTP, settings.proxyType); if (!(flags & NUF_NOHTTPSOPTION)) AddProxyTypeItem(hwndDlg, PROXYTYPE_HTTPS, settings.proxyType); if (flags & (NUF_HTTPCONNS | NUF_HTTPGATEWAY) || !(flags & NUF_NOHTTPSOPTION)) AddProxyTypeItem(hwndDlg, PROXYTYPE_IE, settings.proxyType); SetDlgItemTextA(hwndDlg, IDC_PROXYHOST, settings.szProxyServer ? settings.szProxyServer : ""); if (settings.wProxyPort) SetDlgItemInt(hwndDlg, IDC_PROXYPORT, settings.wProxyPort, FALSE); else SetDlgItemTextA(hwndDlg, IDC_PROXYPORT, ""); CheckDlgButton(hwndDlg, IDC_PROXYAUTH, settings.useProxyAuth ? BST_CHECKED : BST_UNCHECKED); SetDlgItemTextA(hwndDlg, IDC_PROXYUSER, settings.szProxyAuthUser ? settings.szProxyAuthUser : ""); SetDlgItemTextA(hwndDlg, IDC_PROXYPASS, settings.szProxyAuthPassword ? settings.szProxyAuthPassword : ""); CheckDlgButton(hwndDlg, IDC_PROXYDNS, settings.dnsThroughProxy ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_VALIDATESSL, settings.validateSSL ? BST_CHECKED : BST_UNCHECKED); ShowMultipleControls(hwndDlg, incomingConnectionsControls, _countof(incomingConnectionsControls), flags&NUF_INCOMING ? SW_SHOW : SW_HIDE); CheckDlgButton(hwndDlg, IDC_SPECIFYPORTS, settings.specifyIncomingPorts ? BST_CHECKED : BST_UNCHECKED); SetDlgItemTextA(hwndDlg, IDC_PORTSRANGE, settings.szIncomingPorts ? settings.szIncomingPorts : ""); CheckDlgButton(hwndDlg, IDC_SPECIFYPORTSO, settings.specifyOutgoingPorts ? BST_CHECKED : BST_UNCHECKED); SetDlgItemTextA(hwndDlg, IDC_PORTSRANGEO, settings.szOutgoingPorts ? settings.szOutgoingPorts : ""); CheckDlgButton(hwndDlg, IDC_ENABLEUPNP, settings.enableUPnP ? BST_CHECKED : BST_UNCHECKED); NetlibFreeUserSettingsStruct(&settings); SendMessage(hwndDlg, M_REFRESHENABLING, 0, 0); } break; case M_REFRESHENABLING: TCHAR str[80]; { int selectedProxyType = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0); mir_sntprintf(str, _countof(str), TranslateT("(often %d)"), oftenProxyPorts[selectedProxyType]); SetDlgItemText(hwndDlg, IDC_STOFTENPORT, str); if (IsDlgButtonChecked(hwndDlg, IDC_USEPROXY) != BST_UNCHECKED) { int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1; EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), TRUE); if (selectedProxyType == 0) { for (int i = 0; i < tempSettings.getCount(); i++) { NetlibTempSettings *p = tempSettings[i]; if (!p->settings.useProxy || p->flags & NUF_NOOPTIONS || !(p->flags & NUF_OUTGOING)) continue; if (p->settings.proxyType == PROXYTYPE_SOCKS4) enableUser = 1; else { enableAuth = 1; if (p->settings.useProxyAuth) enableUser = enablePass = 1; } } } else { if (selectedProxyType == PROXYTYPE_SOCKS4) enableUser = 1; else { if (selectedProxyType == PROXYTYPE_IE) enableServer = 0; enableAuth = 1; if (IsDlgButtonChecked(hwndDlg, IDC_PROXYAUTH) != BST_UNCHECKED) enableUser = enablePass = 1; } } EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYAUTH), enableAuth); EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC31), enableUser); EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYUSER), enableUser); EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC32), enablePass); EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYPASS), enablePass); EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYHOST), enableServer); EnableWindow(GetDlgItem(hwndDlg, IDC_PROXYPORT), enableServer); } else EnableMultipleControls(hwndDlg, useProxyControls, _countof(useProxyControls), FALSE); EnableMultipleControls(hwndDlg, specifyPortsControls, _countof(specifyPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTS) != BST_UNCHECKED); EnableMultipleControls(hwndDlg, specifyOPortsControls, _countof(specifyOPortsControls), IsDlgButtonChecked(hwndDlg, IDC_SPECIFYPORTSO) != BST_UNCHECKED); } break; case WM_COMMAND: iUser = SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_NETLIBUSERS, CB_GETCURSEL, 0, 0), 0); switch (LOWORD(wParam)) { case IDC_NETLIBUSERS: if (HIWORD(wParam) == CBN_SELCHANGE) SendMessage(hwndDlg, M_REFRESHALL, 0, 0); return 0; case IDC_LOGOPTIONS: NetlibLogShowOptions(); return 0; case IDC_PROXYTYPE: if (HIWORD(wParam) != CBN_SELCHANGE) return 0; { int newValue = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0); if (iUser == -1) { if (newValue == 0) return 0; for (int i=0; i < tempSettings.getCount(); i++) { NetlibTempSettings *p = tempSettings[i]; if (p->flags & NUF_NOOPTIONS) continue; if (newValue == PROXYTYPE_HTTP && !(p->flags & (NUF_HTTPCONNS | NUF_HTTPGATEWAY))) p->settings.proxyType = PROXYTYPE_HTTPS; else if (newValue == PROXYTYPE_HTTPS && p->flags & NUF_NOHTTPSOPTION) p->settings.proxyType = PROXYTYPE_HTTP; else p->settings.proxyType = newValue; } SendMessage(hwndDlg, M_REFRESHALL, 0, 0); } else { tempSettings[iUser]->settings.proxyType = newValue; SendMessage(hwndDlg, M_REFRESHENABLING, 0, 0); } } break; case IDC_USEPROXY: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, useProxy)); break; case IDC_PROXYAUTH: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, useProxyAuth)); break; case IDC_PROXYDNS: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, dnsThroughProxy)); break; case IDC_SPECIFYPORTS: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, specifyIncomingPorts)); break; case IDC_SPECIFYPORTSO: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, specifyOutgoingPorts)); break; case IDC_ENABLEUPNP: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, enableUPnP)); break; case IDC_VALIDATESSL: ChangeSettingIntByCheckbox(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, validateSSL)); break; case IDC_PROXYHOST: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, szProxyServer)); break; case IDC_PROXYPORT: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; { int newValue = GetDlgItemInt(hwndDlg, LOWORD(wParam), NULL, FALSE); if (iUser == -1) { for (int i = 0; i < tempSettings.getCount(); i++) { NetlibTempSettings *p = tempSettings[i]; if (!(p->flags & NUF_NOOPTIONS)) p->settings.wProxyPort = newValue; } } else tempSettings[iUser]->settings.wProxyPort = newValue; } break; case IDC_PROXYUSER: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, szProxyAuthUser)); break; case IDC_PROXYPASS: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, szProxyAuthPassword)); break; case IDC_PORTSRANGE: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, szIncomingPorts)); break; case IDC_PORTSRANGEO: if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) return 0; ChangeSettingStringByEdit(hwndDlg, LOWORD(wParam), iUser, offsetof(NETLIBUSERSETTINGS, szOutgoingPorts)); break; } ShowWindow(GetDlgItem(hwndDlg, IDC_RECONNECTREQD), SW_SHOW); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: for (iUser = 0; iUser < tempSettings.getCount(); iUser++) NetlibSaveUserSettingsStruct(tempSettings[iUser]->szSettingsModule, &tempSettings[iUser]->settings); return TRUE; } break; } break; case WM_DESTROY: for (int i = 0; i < tempSettings.getCount(); ++i) { NetlibTempSettings *p = tempSettings[i]; mir_free(p->szSettingsModule); NetlibFreeUserSettingsStruct(&p->settings); mir_free(tempSettings[i]); } tempSettings.destroy(); break; } return FALSE; }
static void ShowMultipleControls(HWND hwndDlg, const UINT *controls, int cControls, int state) { for (int i = 0; i < cControls; i++) ShowWindow(GetDlgItem(hwndDlg, controls[i]), state); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { WNDCLASS wc; MSG msg; HWND hWnd; wc.lpszClassName = CLASS_NAME; wc.lpfnWndProc = MainWndProc; wc.style = CS_VREDRAW | CS_HREDRAW; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; if (RegisterClass(&wc) == 0) { _ftprintf ( stderr, _T("RegisterClass failed (last error 0x%lX)\n"), GetLastError()); return(1); } hWnd = CreateWindow(CLASS_NAME, APP_NAME, WS_OVERLAPPEDWINDOW, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (hWnd == NULL) { _ftprintf ( stderr, _T("CreateWindow failed (last error 0x%lX)\n"), GetLastError()); return(1); } tf = CreateFont (14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, _T("Timmons")); hbrBackground = CreateSolidBrush ( RGB(192,192,192) ); ShowWindow ( hWnd, nCmdShow ); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } DeleteObject(hbrBackground); DeleteObject(tf); return msg.wParam; }
Window::Window(HINSTANCE instance,const char* windowName,int width,int height) { //Windowclass, defines template for windows WNDCLASSEX wndClass; wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = wEventsProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = instance; wndClass.hIcon = NULL; wndClass.hCursor = NULL; wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = L"windowClass"; wndClass.hIconSm = NULL; //register window class if(!RegisterClassEx(&wndClass)) { //FAIL } //Creates window and return handle to it (a way to access the windows attributes) handle = CreateWindowA("windowClass", windowName, WS_OVERLAPPED, 0, 0, width, height, NULL, NULL, instance, NULL); if (handle == NULL) { //0.o } ShowWindow(handle, SW_SHOWNORMAL); UpdateWindow(handle); //pixel format description, only point worth of notice is if its 32 or 24 bit (alpha or no alpha) PIXELFORMATDESCRIPTOR pixelFormatDesc = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; //Device Contex handle hdc = GetDC(handle); // Gets the display context if(hdc == NULL) { //0.o } int pixelFormat = ChoosePixelFormat(hdc, &pixelFormatDesc); // Chooses the pixel format if(pixelFormat == 0) { //0.o } // Sets the pixel format if(SetPixelFormat(hdc, pixelFormat, &pixelFormatDesc) == 0) { //return 0; } HGLRC hglrc = wglCreateContext(hdc); // Creates the rendering context if(hglrc == NULL) { //0.o } // Attaches the rendering context if(wglMakeCurrent(hdc, hglrc) == 0) { //return 0; } LoadOpenGLFunctions(); // Loads OpenGL 2.1 functions //glViewport(0, 0, width, height); // Sets up the OpenGL viewport MSG msg ={}; Engine* engine = new Engine(); engine->fixAspectRatio(1024,768,width,height); //1024,768 // Main message loop: while(msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else // We've processed all pending Win32 messages, and can now do a rendering update. { } //glClear(GL_COLOR_BUFFER_BIT); engine->Update(); engine->Draw(); SwapBuffers(Window::hdc); // Swaps display buffers } }
/* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UINT uVar; DWORD dwVar; HDC hdc; POINT pt; HBRUSH hbr; TVITEM tvitem; HWND window; void *ptr = NULL; char buf[STK_DEFAULT_SIZE] = {0}; switch (message) /* handle the messages */ { case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_SHOW: ShowWindow(hwnd, SW_RESTORE); SetForegroundWindow(hwnd); break; case IDM_HIDE: case IDM_MIN: ShowWindow(hwnd, SW_HIDE); break; case IDM_EXIT: case IDM_CLOSE: Shell_NotifyIcon(NIM_DELETE, &stkWidget.nid); stk_log("WinMain set STK_EXITING\n"); stk_set_running(STK_EXITING); WaitForSingleObject(socketThread, INFINITE); PostQuitMessage (0); break; case IDM_LOGIN: stk_loginbtn_pressed(); break; case IDM_CANCEL: stk_connectwin_show(FALSE); break; default: window = GetParent((HWND)lParam); if (window != NULL && window != stkWidget.hwnd) { ptr = (void *)stk_find_buddy_by_window(window); if (ptr != NULL) { if (((stk_buddy *)ptr)->chat.closebtn == (HWND)lParam) { SendMessage(((stk_buddy *)ptr)->chat.window, WM_CLOSE, 0, 0); } else if (((stk_buddy *)ptr)->chat.sendbtn == (HWND)lParam) { stk_sendbtn_pressed((stk_buddy *)ptr); } } else { int num; BOOL found = FALSE; stk_group *group; num = client.group_num; group = client.group; while (num-- && group != NULL) { if (group->gchat.window == window) { found = TRUE; break; } group = group->next; } if (found && group != NULL) { if (group->gchat.closebtn == (HWND)lParam) { SendMessage(group->gchat.window, WM_CLOSE, 0, 0); } else if (group->gchat.sendbtn == (HWND)lParam) { stk_gsendbtn_pressed(group); } } } } break; } break; case WM_NCHITTEST: uVar = DefWindowProc(hwnd, message, wParam, lParam); if(uVar == HTCLIENT && GetAsyncKeyState(MK_LBUTTON) < 0) { uVar = HTCAPTION; } return uVar; case WMAPP_TRAY: switch (LOWORD(lParam)) { case WM_LBUTTONDBLCLK: ShowWindow(hwnd, SW_RESTORE); SetForegroundWindow(hwnd); break; case WM_RBUTTONUP: case WM_CONTEXTMENU: GetCursorPos(&pt); uVar = TPM_RIGHTBUTTON; SetForegroundWindow(hwnd); // respect menu drop alignment if (GetSystemMetrics(SM_MENUDROPALIGNMENT) != 0) uVar |= TPM_RIGHTALIGN; else uVar |= TPM_LEFTALIGN; TrackPopupMenuEx(stkWidget.menu, uVar, pt.x, pt.y, hwnd, NULL); break; } break; case WMAPP_SOCKET: uVar = stk_get_running(); switch(uVar) { case STK_SOCKET_ERR: case STK_CONNECTE_ERR: strcpy(buf, "Connect to stkserver falied."); break; case STK_USERID_ERR: strcpy(buf, "Invalid Username."); break; case STK_PASSWORD_ERR: strcpy(buf, "Invalid Password."); break; case STK_ALREADY_LOGGIN: strcpy(buf, "Already Logined in."); break; case STK_CONNECTED: sprintf(buf, "%s:%d(%s)", STKCLIENT, client.uid, client.nickname); strcpy(stkWidget.nid.szTip, buf); stk_buddywin_create(); stk_set_running(STK_RUNNING); stk_log("User %d Login in.\n", client.uid); return; default: break; } if (buf[0] != '\0') { /* Login failed */ SetWindowText(loginWidget.resultlabel, buf); stk_connectwin_show(FALSE); UpdateWindow(stkWidget.hwnd); stk_set_running(STK_INITIALIZED); } break; case WMAPP_MSG: if ((BOOL)wParam) { stk_gchatwin_display((stk_group *)lParam); } else { stk_chatwin_display((stk_buddy *)lParam); } case WM_NOTIFY: if(LOWORD(wParam) == IDM_TABCTRL) { if(((LPNMHDR)lParam)->code == TCN_SELCHANGE) { uVar = TabCtrl_GetCurSel(stkWidget.tabcontrol); switch(uVar) { case STK_TREE_BUDDY: ShowWindow(stkWidget.buddytreeview, SW_SHOW); ShowWindow(stkWidget.grouptreeview, SW_HIDE); break; case STK_TREE_GROUP: ShowWindow(stkWidget.buddytreeview, SW_HIDE); ShowWindow(stkWidget.grouptreeview, SW_SHOW); break; } } } else if ((LOWORD(wParam) == IDM_BUDDYTREE) || (LOWORD(wParam) == IDM_GROUPTREE)) { /* Just action with left double click */ if(((LPNMHDR)lParam)->code == NM_DBLCLK) { memset(&tvitem, 0, sizeof(tvitem)); tvitem.hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);; tvitem.mask = TVIF_TEXT; tvitem.pszText = buf; tvitem.cchTextMax = STK_DEFAULT_SIZE; TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvitem); dwVar = atoi(strtok(buf," ")); if (LOWORD(wParam) == IDM_BUDDYTREE) stk_chatwin_show((int)dwVar); else stk_gchatwin_show((int)dwVar); } } break; case WM_CREATE: if (hwnd == stkWidget.hwnd) { dwVar = GetWindowLong(hwnd, GWL_EXSTYLE); dwVar |= WS_EX_TOOLWINDOW | WS_EX_APPWINDOW; SetWindowLong(hwnd, GWL_EXSTYLE, dwVar); } break; //case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: if ((stk_get_running() == STK_RUNNING) && (hwnd != stkWidget.profilelabel)) { /* * Read-only or disabled edit controls do not send the WM_CTLCOLOREDIT message; * instead, they send the WM_CTLCOLORSTATIC message. */ hdc = (HDC)wParam; hbr = (HBRUSH)CreateSolidBrush(RGB(255,255,255)); //SetTextColor(hdc, RGB(255,255,255)); SetBkColor(hdc, RGB(255,255,255)); return (LRESULT)hbr; } else { hdc = (HDC)wParam; hbr = (HBRUSH)CreateSolidBrush(DEFAULT_RGB); //SetTextColor(hdc, RGB(255,255,255)); SetBkColor(hdc, DEFAULT_RGB); if ((HWND)lParam == loginWidget.resultlabel) { SetTextColor(hdc, RGB(255,0,0)); } return (LRESULT)hbr; } case WM_DESTROY: if (hwnd == stkWidget.hwnd) { Shell_NotifyIcon(NIM_DELETE, &stkWidget.nid); stk_log("WinMain set STK_EXITING\n"); stk_set_running(STK_EXITING); WaitForSingleObject(socketThread, INFINITE); PostQuitMessage (0); } else { ptr = (void *)stk_find_buddy_by_window(hwnd); if (ptr == NULL) { int num; BOOL found = FALSE; stk_group *group; num = client.group_num; group = client.group; while (num-- && group != NULL) { if (group->gchat.window == hwnd) { found = TRUE; break; } group = group->next; } if (found && group != NULL) { group->gchat.exist = 0; group->gchat.window = NULL; } } else { ((stk_buddy *)ptr)->chat.exist = 0; ((stk_buddy *)ptr)->chat.window = NULL; } } break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ HICON icon; /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = STKCLIENT; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mousee-pointer */ /* Note: hIconSm is window title icon, hIcon is program icon */ icon = (HICON)LoadImage(NULL, STK_CLIENT_ICO, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); wincl.hIcon = icon; wincl.hIconSm = icon; wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = CreateSolidBrush(DEFAULT_RGB); /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* Register chat window class*/ //stk_chatwin_register(); /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ STKCLIENT, /* Classname */ STKCLIENT, /* Title Text */ WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX, /* ÎÞ±êÌâÀ¸´°¿Ú */ 950, /* Windows decides the position */ 80, /* where the window ends up on the screen */ STK_MAINWIN_WIDTH, /* The programs width */ STK_MAINWIN_HEIGHT, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Store hwnd to global var */ stkWidget.hins = hThisInstance; stkWidget.hwnd = hwnd; /* add tray */ stkWidget.nid.cbSize = sizeof(stkWidget.nid); stkWidget.nid.hWnd = hwnd; stkWidget.nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; stkWidget.nid.uCallbackMessage = WMAPP_TRAY; stkWidget.nid.hIcon = icon; strcpy(stkWidget.nid.szTip, STKCLIENT); Shell_NotifyIcon(NIM_ADD, &stkWidget.nid); /* STK UI */ stk_create_ui(hwnd); /* init global vars and socket thread */ memset(&client, 0, sizeof(client)); stk_init_running(); socketThread = CreateThread(0, 0, stk_socket, (void*)&client, 0, NULL); /* Make the window visible on the screen */ ShowWindow(hwnd, nFunsterStil); /* Let socket know we have done the initialization*/ stk_log("WinMain set STK_INITIALIZED\n"); stk_set_running(STK_INITIALIZED); /* 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); if (messages.message == WM_KEYDOWN && messages.wParam == VK_TAB) { if (stk_get_running() == STK_INITIALIZED) { /* Press Tab, switch focus */ SetTabFocus(hwnd); } } else if (messages.message == WM_KEYDOWN && messages.wParam == VK_RETURN) { if (stk_get_running() == STK_INITIALIZED) { /* Press Enter, Login in */ stk_loginbtn_pressed(); } } else { /* Send message to WindowProcedure */ DispatchMessage(&messages); } } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { PF_CONSOLE_INIT_ALL() // Set global handle gHInst = hInst; CCmdParser cmdParser(s_cmdLineArgs, arrsize(s_cmdLineArgs)); cmdParser.Parse(); bool doIntroDialogs = true; #ifndef PLASMA_EXTERNAL_RELEASE if (cmdParser.IsSpecified(kArgSkipLoginDialog)) doIntroDialogs = false; if (cmdParser.IsSpecified(kArgLocalData)) { gDataServerLocal = true; gSkipPreload = true; } if (cmdParser.IsSpecified(kArgSkipPreload)) gSkipPreload = true; #endif plFileName serverIni = "server.ini"; if (cmdParser.IsSpecified(kArgServerIni)) serverIni = plString::FromWchar(cmdParser.GetString(kArgServerIni)); // check to see if we were launched from the patcher bool eventExists = false; // we check to see if the event exists that the patcher should have created HANDLE hPatcherEvent = CreateEventW(nil, TRUE, FALSE, L"UruPatcherEvent"); if (hPatcherEvent != NULL) { // successfully created it, check to see if it was already created if (GetLastError() == ERROR_ALREADY_EXISTS) { // it already existed, so the patcher is waiting, signal it so the patcher can die SetEvent(hPatcherEvent); eventExists = true; } } #ifdef PLASMA_EXTERNAL_RELEASE // if the client was started directly, run the patcher, and shutdown STARTUPINFOW si; PROCESS_INFORMATION pi; memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi)); si.cb = sizeof(si); const char** addrs; if (!eventExists) // if it is missing, assume patcher wasn't launched { plStringStream cmdLine; GetAuthSrvHostnames(&addrs); if (strlen(addrs[0])) cmdLine << " /AuthSrv=" << addrs[0]; GetFileSrvHostnames(&addrs); if (strlen(addrs[0])) cmdLine << " /FileSrv=" << addrs[0]; GetGateKeeperSrvHostnames(&addrs); if (strlen(addrs[0])) cmdLine << " /GateKeeperSrv=" << addrs[0]; if(!CreateProcessW(s_patcherExeName, (LPWSTR)cmdLine.GetString().ToUtf16().GetData(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal); } CloseHandle( pi.hThread ); CloseHandle( pi.hProcess ); return PARABLE_NORMAL_EXIT; } #endif // Load an optional general.ini plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini"); FILE *generalini = plFileSystem::Open(gipath, "rb"); if (generalini) { fclose(generalini); pfConsoleEngine tempConsole; tempConsole.ExecuteFile(gipath); } #ifdef PLASMA_EXTERNAL_RELEASE // If another instance is running, exit. We'll automatically release our // lock on the mutex when our process exits HANDLE hOneInstance = CreateMutex(nil, FALSE, "UruExplorer"); if (WaitForSingleObject(hOneInstance,0) != WAIT_OBJECT_0) { switch (plLocalization::GetLanguage()) { case plLocalization::kFrench: hsMessageBox("Une autre copie d'URU est déjà en cours d'exécution", "Erreur", hsMessageBoxNormal); break; case plLocalization::kGerman: hsMessageBox("URU wird bereits in einer anderen Instanz ausgeführt", "Fehler", hsMessageBoxNormal); break; case plLocalization::kSpanish: hsMessageBox("En estos momentos se está ejecutando otra copia de URU", "Error", hsMessageBoxNormal); break; case plLocalization::kItalian: hsMessageBox("Un'altra copia di URU è già aperta", "Errore", hsMessageBoxNormal); break; // default is English default: hsMessageBox("Another copy of URU is already running", "Error", hsMessageBoxNormal); break; } return PARABLE_NORMAL_EXIT; } #endif FILE *serverIniFile = plFileSystem::Open(serverIni, "rb"); if (serverIniFile) { fclose(serverIniFile); pfConsoleEngine tempConsole; tempConsole.ExecuteFile(serverIni); } else { hsMessageBox("No server.ini file found. Please check your URU installation.", "Error", hsMessageBoxNormal); return PARABLE_NORMAL_EXIT; } NetCliAuthAutoReconnectEnable(false); NetCommSetReadIniAccountInfo(!doIntroDialogs); InitNetClientComm(); curl_global_init(CURL_GLOBAL_ALL); bool needExit = false; LoginDialogParam loginParam; memset(&loginParam, 0, sizeof(loginParam)); LoadUserPass(&loginParam); if (!doIntroDialogs && loginParam.remember) { ENetError auth; wchar_t wusername[kMaxAccountNameLength]; StrToUnicode(wusername, loginParam.username, arrsize(wusername)); NetCommSetAccountUsernamePassword(wusername, loginParam.namePassHash); bool cancelled = AuthenticateNetClientComm(&auth, NULL); if (IS_NET_ERROR(auth) || cancelled) { doIntroDialogs = true; loginParam.authError = auth; if (cancelled) { NetCommDisconnect(); } } } if (doIntroDialogs) { needExit = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_MAIN ), NULL, UruLoginDialogProc, (LPARAM)&loginParam ) <= 0; } if (doIntroDialogs && !needExit) { HINSTANCE hRichEdDll = LoadLibrary("RICHED20.DLL"); INT_PTR val = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_EULA ), NULL, UruTOSDialogProc, (LPARAM)hInst); FreeLibrary(hRichEdDll); if (val <= 0) { DWORD error = GetLastError(); needExit = true; } } curl_global_cleanup(); if (needExit) { DeInitNetClientComm(); return PARABLE_NORMAL_EXIT; } NetCliAuthAutoReconnectEnable(true); // VERY VERY FIRST--throw up our splash screen HWND splashDialog = ::CreateDialog( hInst, MAKEINTRESOURCE( IDD_LOADING ), NULL, SplashDialogProc ); // Install our unhandled exception filter for trapping all those nasty crashes in release build #ifndef HS_DEBUGGING LPTOP_LEVEL_EXCEPTION_FILTER oldFilter; oldFilter = SetUnhandledExceptionFilter( plCustomUnhandledExceptionFilter ); #endif // // Set up to log errors by using hsDebugMessage // DebugInit(); DebugMsgF("Plasma 2.0.%i.%i - %s", PLASMA2_MAJOR_VERSION, PLASMA2_MINOR_VERSION, plProduct::ProductString().c_str()); for (;;) { // Create Window if (!WinInit(hInst, nCmdShow) || gClient->GetDone()) break; // We don't have multiplayer localized assets for Italian or Spanish, so force them to English in that case. /* if (!plNetClientMgr::GetInstance()->InOfflineMode() && (plLocalization::GetLanguage() == plLocalization::kItalian || plLocalization::GetLanguage() == plLocalization::kSpanish)) { plLocalization::SetLanguage(plLocalization::kEnglish); } */ // Done with our splash now ::DestroyWindow( splashDialog ); if (!gClient) break; // Show the main window ShowWindow(gClient->GetWindowHandle(), SW_SHOW); gHasMouse = GetSystemMetrics(SM_MOUSEPRESENT); // Be really REALLY forceful about being in the front BringWindowToTop( gClient->GetWindowHandle() ); // Update the window UpdateWindow(gClient->GetWindowHandle()); // // Init Application here // if( !gClient->StartInit() ) break; // I want it on top! I mean it! BringWindowToTop( gClient->GetWindowHandle() ); // initialize dinput here: if (gClient && gClient->GetInputManager()) gClient->GetInputManager()->InitDInput(hInst, (HWND)gClient->GetWindowHandle()); // Seriously! BringWindowToTop( gClient->GetWindowHandle() ); // // Main loop // MSG msg; do { gClient->MainLoop(); if( gClient->GetDone() ) break; // Look for a message while (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) { // Handle the message TranslateMessage( &msg ); DispatchMessage( &msg ); } } while (WM_QUIT != msg.message); break; } // // Cleanup // if (gClient) { gClient->Shutdown(); // shuts down PhysX for us gClient = nil; } hsAssert(hsgResMgr::ResMgr()->RefCnt()==1, "resMgr has too many refs, expect mem leaks"); hsgResMgr::Shutdown(); // deletes fResMgr DeInitNetClientComm(); // Uninstall our unhandled exception filter, if we installed one #ifndef HS_DEBUGGING SetUnhandledExceptionFilter( oldFilter ); #endif // Exit WinMain and terminate the app.... // return msg.wParam; return PARABLE_NORMAL_EXIT; }
void COXToolTipCtrl::Pop() { ShowWindow(SW_HIDE); m_bTipCancelled = TRUE; m_pCurrentToolTip = NULL; }
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { 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 WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left=(long)0; // Set Left Value To 0 WindowRect.right=(long)width; // Set Right Value To Requested Width WindowRect.top=(long)0; // Set Top Value To 0 WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height fullscreen=fullscreenflag; // Set The Global Fullscreen Flag 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 = 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(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (fullscreen) // Attempt Fullscreen Mode? { DEVMODE dmScreenSettings; // Device Mode memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode. if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE } else { // Pop Up A Message Box Letting User Know The Program Is Closing. MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); return FALSE; // Return FALSE } } } if (fullscreen) // Are We Still In Fullscreen Mode? { dwExStyle=WS_EX_APPWINDOW; // Window Extended Style dwStyle=WS_POPUP; // Windows Style ShowCursor(FALSE); // Hide Mouse Pointer } else { dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size // Create The Window if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window "OpenGL", // Class Name title, // 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 hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { KillGLWindow(); // Reset The Display MessageBox(NULL,"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 bits, // 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 }; if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } return TRUE; // Success }
static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_USER + 1: { HANDLE hContact = (HANDLE) wParam; DBCONTACTWRITESETTING *ws = (DBCONTACTWRITESETTING *) lParam; if (hContact == NULL && ws != NULL && ws->szModule != NULL && ws->szSetting != NULL && lstrcmpiA(ws->szModule, "CList") == 0 && lstrcmpiA(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg)) { CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, ws->value.bVal == 0); } break; } case WM_DESTROY: { UnhookEvent((HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); break; } case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) HookEventMessage(ME_DB_CONTACT_SETTINGCHANGED, hwndDlg, WM_USER + 1)); CheckDlgButton(hwndDlg, IDC_ONTOP, db_get_b(NULL, "CList", "OnTop", SETTING_ONTOP_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE, db_get_b(NULL, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_HIDEEMPTYGROUPS, db_get_b(NULL, "CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_SORTBYNAME, !db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT) && !db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SORTBYSTATUS, db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SORTBYPROTO, db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CONFIRMDELETE, db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTOHIDE, db_get_b(NULL, "CList", "AutoHide", SETTING_AUTOHIDE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIME), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); { DWORD caps = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS1, 0); if (!(caps & CLUIF_HIDEEMPTYGROUPS)) ShowWindow(GetDlgItem(hwndDlg, IDC_HIDEEMPTYGROUPS), SW_HIDE); if (!(caps & CLUIF_DISABLEGROUPS)) ShowWindow(GetDlgItem(hwndDlg, IDC_DISABLEGROUPS), SW_HIDE); if (caps & CLUIF_HASONTOPOPTION) ShowWindow(GetDlgItem(hwndDlg, IDC_ONTOP), SW_HIDE); if (caps & CLUIF_HASAUTOHIDEOPTION) { ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOHIDE), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_HIDETIME), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_HIDETIMESPIN), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_STAUTOHIDESECS), SW_HIDE); } } SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_SETRANGE, 0, MAKELONG(900, 1)); SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "HideTime", SETTING_HIDETIME_DEFAULT), 0)); CheckDlgButton(hwndDlg, IDC_ONECLK, db_get_b(NULL, "CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ALWAYSSTATUS, db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ALWAYSMULTI, !db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DONTCYCLE, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_CYCLE, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_CYCLE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_MULTITRAY, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DISABLEBLINK, db_get_b(NULL, "CList", "DisableTrayFlash", 0) == 1 ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKTIME), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKSPIN), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); EnableWindow(GetDlgItem(hwndDlg, IDC_STMSDELAY), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); CheckDlgButton(hwndDlg, IDC_ICONBLINK, db_get_b(NULL, "CList", "NoIconBlink", 0) == 1 ? BST_CHECKED : BST_UNCHECKED); if (IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE)) { EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), FALSE); } if (IsDlgButtonChecked(hwndDlg, IDC_CYCLE)) { EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), FALSE); } if (IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY)) { EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), FALSE); } SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETRANGE, 0, MAKELONG(120, 1)); SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT), 0)); { int i, count, item; PROTOACCOUNT **accs; DBVARIANT dbv = { DBVT_DELETED }; db_get(NULL, "CList", "PrimaryStatus", &dbv); CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accs); item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM) TranslateT("Global")); SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM) 0); for (i = 0; i < count; i++) { if (!IsAccountEnabled(accs[i]) || CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0) continue; item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM) accs[i]->tszAccountName); SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM) accs[i]); if (dbv.type == DBVT_ASCIIZ && !lstrcmpA(dbv.pszVal, accs[i]->szModuleName)) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0); } db_free(&dbv); } if (-1 == (int) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0)) SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETBUDDY, (WPARAM) GetDlgItem(hwndDlg, IDC_BLINKTIME), 0); // set buddy SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE, 0, MAKELONG(0x3FFF, 250)); SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "IconFlashTime", 550), 0)); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDC_AUTOHIDE) { EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIME), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); EnableWindow(GetDlgItem(hwndDlg, IDC_HIDETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); } if (LOWORD(wParam) == IDC_DONTCYCLE || LOWORD(wParam) == IDC_CYCLE || LOWORD(wParam) == IDC_MULTITRAY) { EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE)); EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), IsDlgButtonChecked(hwndDlg, IDC_CYCLE)); EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_CYCLE)); EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY)); } if (LOWORD(wParam) == IDC_DISABLEBLINK) { EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKTIME), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); EnableWindow(GetDlgItem(hwndDlg, IDC_BLINKSPIN), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); EnableWindow(GetDlgItem(hwndDlg, IDC_STMSDELAY), !IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); } if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && HIWORD(wParam) != EN_CHANGE) break; if (LOWORD(wParam) == IDC_PRIMARYSTATUS && HIWORD(wParam) != CBN_SELCHANGE) break; if ((LOWORD(wParam) == IDC_HIDETIME || LOWORD(wParam) == IDC_CYCLETIME) && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())) return 0; if (LOWORD(wParam) == IDC_BLINKTIME && HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()) return 0; // dont make apply enabled during buddy set crap SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case WM_NOTIFY: switch (((LPNMHDR) lParam)->idFrom) { case 0: switch (((LPNMHDR) lParam)->code) { case PSN_APPLY: db_set_b(NULL, "CList", "HideOffline", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE)); { DWORD caps = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS1, 0); if (caps & CLUIF_HIDEEMPTYGROUPS) db_set_b(NULL, "CList", "HideEmptyGroups", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDEEMPTYGROUPS)); if (caps & CLUIF_DISABLEGROUPS) db_set_b(NULL, "CList", "UseGroups", (BYTE) ! IsDlgButtonChecked(hwndDlg, IDC_DISABLEGROUPS)); if (!(caps & CLUIF_HASONTOPOPTION)) { db_set_b(NULL, "CList", "OnTop", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ONTOP)); SetWindowPos( pcli->hwndContactList, IsDlgButtonChecked(hwndDlg, IDC_ONTOP) ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } if (!(caps & CLUIF_HASAUTOHIDEOPTION)) { db_set_b(NULL, "CList", "AutoHide", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE)); db_set_w(NULL, "CList", "HideTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0)); } } db_set_b(NULL, "CList", "SortByStatus", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS)); db_set_b(NULL, "CList", "SortByProto", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO)); db_set_b(NULL, "CList", "ConfirmDelete", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE)); db_set_b(NULL, "CList", "Tray1Click", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ONECLK)); db_set_b(NULL, "CList", "AlwaysStatus", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS)); db_set_b(NULL, "CList", "AlwaysMulti", (BYTE) ! IsDlgButtonChecked(hwndDlg, IDC_ALWAYSMULTI)); db_set_b(NULL, "CList", "TrayIcon", (BYTE) (IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE) ? SETTING_TRAYICON_SINGLE : (IsDlgButtonChecked(hwndDlg, IDC_CYCLE) ? SETTING_TRAYICON_CYCLE : SETTING_TRAYICON_MULTI))); db_set_w(NULL, "CList", "CycleTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_GETPOS, 0, 0)); db_set_w(NULL, "CList", "IconFlashTime", (WORD) SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_GETPOS, 0, 0)); db_set_b(NULL, "CList", "DisableTrayFlash", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK)); db_set_b(NULL, "CList", "NoIconBlink", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ICONBLINK)); { int cur = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0); PROTOACCOUNT* pa = ( PROTOACCOUNT* )SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, cur, 0 ); if ( pa == NULL ) db_unset(NULL, "CList", "PrimaryStatus"); else db_set_s(NULL, "CList", "PrimaryStatus", pa->szModuleName ); } pcli->pfnTrayIconIconsChanged(); pcli->pfnLoadContactTree(); /* this won't do job properly since it only really works when changes happen */ pcli->pfnInvalidateDisplayNameCacheEntry( INVALID_HANDLE_VALUE ); /* force reshuffle */ return TRUE; } break; } break; } return FALSE; }
BOOL InitD3D(HINSTANCE hInstance) { WNDCLASS wndClass; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.hInstance = hInstance; wndClass.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.lpfnWndProc = WndProc; wndClass.lpszClassName = g_szClassName; wndClass.lpszMenuName = NULL; BOOL bRet; bRet = RegisterClass(&wndClass); if (!bRet) { MessageBox(NULL, _T("RegisterClass Failed"), NULL, MB_OK); return FALSE; } HWND hWnd; hWnd = CreateWindow(g_szClassName, g_szWindowTitle, WS_OVERLAPPEDWINDOW | WS_EX_TOPMOST, g_xPos, g_yPos, g_cxWindow, g_cyWindow, NULL, NULL, hInstance, NULL); if (!hWnd) { MessageBox(NULL, _T("CreateWindow Failed"), NULL, MB_OK); return FALSE; } ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); //DirectX初始化 1 获取Direct3D9接口指针 IDirect3D9 * pD3D = Direct3DCreate9(D3D_SDK_VERSION); if (!pD3D) { MessageBox(NULL, _T("Direct3DCreate9 Failed"), NULL, MB_OK); return FALSE; } //DirectX初始化 2 检查设备能力 D3DCAPS9 caps; pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps); int vp; //顶点处理类型 if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) vp = D3DCREATE_HARDWARE_VERTEXPROCESSING; else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING; //DirectX初始化 3 初始化D3DPRESENT_PARAMETERS结构体 D3DPRESENT_PARAMETERS d3dpp; d3dpp.BackBufferWidth = g_cxWindow; d3dpp.BackBufferHeight = g_cyWindow; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; d3dpp.MultiSampleQuality = 0; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.hDeviceWindow = hWnd; d3dpp.Windowed = true; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; d3dpp.Flags = 0; d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; //DirectX初始化 4 创建IDirect3DDevice对象 LRESULT hr = pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, vp, &d3dpp, &g_pDevice); if (FAILED(hr)) { MessageBox(NULL, _T("CreateDevice Failed"), NULL, MB_OK); return FALSE; } pD3D->Release(); //设置 if (!Setup()) { MessageBox(NULL, _T("Setup Failed"), NULL, MB_OK); return FALSE; } return TRUE; }
void UpdateSizeTip(HWND src, int cx, int cy) { TCHAR str[32]; if (!tip_enabled) return; if (!tip_wnd) { NONCLIENTMETRICS nci; /* First make sure the window class is registered */ if (!tip_class) { WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = SizeTipWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinst; wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "SizeTipClass"; tip_class = RegisterClass(&wc); } #if 0 /* Default values based on Windows Standard color scheme */ tip_font = GetStockObject(SYSTEM_FONT); tip_bg = RGB(255, 255, 225); tip_text = RGB(0, 0, 0); #endif /* Prepare other GDI objects and drawing info */ tip_bg = GetSysColor(COLOR_INFOBK); tip_text = GetSysColor(COLOR_INFOTEXT); memset(&nci, 0, sizeof(NONCLIENTMETRICS)); nci.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &nci, 0); tip_font = CreateFontIndirect(&nci.lfStatusFont); } /* Generate the tip text */ sprintf(str, "%dx%d", cx, cy); if (!tip_wnd) { HDC hdc; SIZE sz; RECT wr; int ix, iy; /* calculate the tip's size */ hdc = CreateCompatibleDC(NULL); GetTextExtentPoint32(hdc, str, (int)_tcslen(str), &sz); DeleteDC(hdc); GetWindowRect(src, &wr); ix = wr.left; if (ix < 16) ix = 16; iy = wr.top - sz.cy; if (iy < 16) iy = 16; /* Create the tip window */ tip_wnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, MAKEINTRESOURCE(tip_class), str, WS_POPUP, ix, iy, sz.cx, sz.cy, NULL, NULL, hinst, NULL); ShowWindow(tip_wnd, SW_SHOWNOACTIVATE); } else { /* Tip already exists, just set the text */ SetWindowText(tip_wnd, str); } }
void pxWindow::setVisibility(bool visible) { if (visible) ShowWindow(mWindowRef); else HideWindow(mWindowRef); }
bool Window::configInitAGLWindow() { AGLContext context = getAGLContext(); if( !context ) { setError( ERROR_AGLWINDOW_NO_CONTEXT ); return false; } // window const bool decoration = getIAttribute(eq::Window::IATTR_HINT_DECORATION) != OFF; WindowAttributes winAttributes = ( decoration ? kWindowStandardDocumentAttributes : kWindowNoTitleBarAttribute | kWindowNoShadowAttribute | kWindowResizableAttribute ) | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute; // top, left, bottom, right const PixelViewport pvp = getWindow()->getPixelViewport(); const int32_t menuHeight = decoration ? EQ_AGL_MENUBARHEIGHT : 0 ; Rect windowRect = { pvp.y + menuHeight, pvp.x, pvp.y + pvp.h + menuHeight, pvp.x + pvp.w }; WindowRef windowRef; Global::enterCarbon(); const OSStatus status = CreateNewWindow( kDocumentWindowClass, winAttributes, &windowRect, &windowRef ); if( status != noErr ) { setError( ERROR_AGLWINDOW_CREATEWINDOW_FAILED ); LBWARN << getError() << ": " << status << std::endl; Global::leaveCarbon(); return false; } // window title const std::string& name = getWindow()->getName(); std::stringstream windowTitle; if( name.empty( )) { windowTitle << "Equalizer"; #ifndef NDEBUG windowTitle << " (" << getpid() << ")"; #endif; } else windowTitle << name; CFStringRef title = CFStringCreateWithCString( kCFAllocatorDefault, windowTitle.str().c_str(), kCFStringEncodingMacRoman ); SetWindowTitleWithCFString( windowRef, title ); CFRelease( title ); if( !aglSetWindowRef( context, windowRef )) { setError( ERROR_AGLWINDOW_SETWINDOW_FAILED ); LBWARN << getError() << ": " << AGLERROR << std::endl; Global::leaveCarbon(); return false; } // show ShowWindow( windowRef ); // Do focus hell ProcessSerialNumber selfProcess = { 0, kCurrentProcess }; SetFrontProcess( &selfProcess ); Global::leaveCarbon(); setCarbonWindow( windowRef ); return true; }
//显示窗口 void Display( HWND hWnd ) { ShowWindow( hWnd, SW_SHOW ); UpdateWindow( hWnd ); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { // Initialize common controls to get the new style controls, also // dependent on manifest file InitCommonControls(); // Check for a previous instance of this app if (!hPrevInstance) if (!RegisterMainClass(hInstance)) return FALSE; // Save the application-instance handle. hInst = hInstance; // Register knob class RegisterKnobClass(hInstance); // Create the main window. window.hwnd = CreateWindow(WCLASS, "Selective Level Measuring Set", WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, WIDTH, HEIGHT, NULL, 0, hInst, NULL); // If the main window cannot be created, terminate // the application. if (!window.hwnd) return FALSE; // Show the window and send a WM_PAINT message to the window // procedure. ShowWindow(window.hwnd, nCmdShow); UpdateWindow(window.hwnd); // Process messages MSG msg; BOOL flag; while ((flag = GetMessage(&msg, (HWND)NULL, 0, 0)) != 0) { if (flag == -1) break; TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
static HWND toglCreateTestWindow(HWND parent) { static char ClassName[] = "ToglTestWindow"; WNDCLASS wc; HINSTANCE instance = GetModuleHandle(NULL); HWND wnd; HDC dc; PIXELFORMATDESCRIPTOR pfd; int pixelFormat; wc.style = CS_OWNDC; wc.lpfnWndProc = DefWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = instance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = ClassName; if (!RegisterClass(&wc)) { DWORD err = GetLastError(); if (err != ERROR_CLASS_ALREADY_EXISTS) { fprintf(stderr, "Unable to register Togl Test Window class\n"); return NULL; } } wnd = CreateWindow(ClassName, "test OpenGL capabilities", WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 1, 1, parent, NULL, instance, NULL); if (wnd == NULL) { fprintf(stderr, "Unable to create temporary OpenGL window\n"); return NULL; } dc = GetDC(wnd); memset(&pfd, 0, sizeof pfd); pfd.nSize = sizeof pfd; pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 3; pfd.iLayerType = PFD_MAIN_PLANE; pixelFormat = ChoosePixelFormat(dc, &pfd); if (pixelFormat == 0) { fprintf(stderr, "Unable to choose simple pixel format\n"); ReleaseDC(wnd, dc); return NULL; } if (!SetPixelFormat(dc, pixelFormat, &pfd)) { fprintf(stderr, "Unable to set simple pixel format\n"); ReleaseDC(wnd, dc); return NULL; } ShowWindow(wnd, SW_HIDE); // make sure it's hidden ReleaseDC(wnd, dc); return wnd; }
int App::run(void) { const char *QUICK_COCOS2DX_ROOT = getenv("QUICK_COCOS2DX_ROOT"); SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(QUICK_COCOS2DX_ROOT); loadProjectConfig(); HWND hwndConsole = NULL; if (m_project.isShowConsole()) { AllocConsole(); freopen("CONOUT$", "wt", stdout); freopen("CONOUT$", "wt", stderr); // disable close console hwndConsole = GetConsoleWindow(); if (hwndConsole != NULL) { HMENU hMenu = GetSystemMenu(hwndConsole, FALSE); if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); ShowWindow(hwndConsole, SW_SHOW); BringWindowToTop(hwndConsole); } } m_project.dump(); if (m_project.isWriteDebugLogToFile()) { const string debugLogFilePath = m_project.getDebugLogFilePath(); m_writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w"); if (!m_writeDebugLogFile) { CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str()); } } do { m_exit = TRUE; // create the application instance m_app = new AppDelegate(); m_app->setProjectConfig(m_project); // set environments SetCurrentDirectoryA(m_project.getProjectDir().c_str()); CCFileUtils::sharedFileUtils()->setSearchRootPath(m_project.getProjectDir().c_str()); CCFileUtils::sharedFileUtils()->setWritablePath(m_project.getWritableRealPath().c_str()); // create opengl view CCEGLView* eglView = CCEGLView::sharedOpenGLView(); eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32)); eglView->setWndProc(WindowProc); eglView->setFrameSize(m_project.getFrameSize().width, m_project.getFrameSize().height); eglView->setFrameZoomFactor(m_project.getFrameScale()); // make window actived m_hwnd = eglView->getHWnd(); BringWindowToTop(m_hwnd); SetWindowTextA(m_hwnd, "projectgame"); // restore window position const CCPoint windowOffset = m_project.getWindowOffset(); if (windowOffset.x != 0 || windowOffset.y != 0) { eglView->moveWindow(windowOffset.x, windowOffset.y); } // set icon HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32)); SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon); if (hwndConsole) { SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon); } // update menu createViewMenu(); updateMenu(); // run game CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack(); const vector<string> arr = m_project.getPackagePathArray(); for (vector<string>::const_iterator it = arr.begin(); it != arr.end(); ++it) { stack->addSearchPath(it->c_str()); } m_app->run(); // cleanup CCScriptEngineManager::sharedManager()->removeScriptEngine(); CCScriptEngineManager::purgeSharedManager(); CocosDenshion::SimpleAudioEngine::end(); delete m_app; m_app = NULL; } while (!m_exit); FreeConsole(); if (m_writeDebugLogFile) fclose(m_writeDebugLogFile); return 0; }
BOOL InitInstance ( HANDLE hInstance, INT nCmdShow ) /*++ Routine Description: Saves instance handle and creates main window This function is called at initialization time for every instance of this application. This function performs initialization tasks that cannot be shared by multiple instances. In this case, we save the instance handle in a static variable and create and display the main program window. Arguments: hInstance - Current instance identifier nComShow - Param for first ShowWindow() call. Return Value: TRUE/FALSE --*/ { // // Save the instance handle in static variable, which will be used in // many subsequence calls from this application to Windows. // hInstApp = hInstance; // // Create a main window for this application instance. // hWndApp = CreateWindow( ClassName, TitleName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); if (NULL != hWndApp) { // // Make the window visible; update its client area; // and send WM_PAINT message // ShowWindow(hWndApp, nCmdShow); UpdateWindow(hWndApp); } return ((hWndApp) ? TRUE : FALSE); }
BOOL CreateGLWindow(char* title, int width, int height, int bit, bool fullScreenFlag) { GLuint PixelFormat; WNDCLASS wc; DWORD dwExStyle; DWORD dwStyle; RECT WindowRect; WindowRect.left = 0; WindowRect.right = width; WindowRect.top = 0; WindowRect.bottom = height; fullscreen = fullScreenFlag; hInstance = GetModuleHandle(NULL); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = L"OpenGL"; RegisterClass(&wc); dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_OVERLAPPEDWINDOW; AdjustWindowRectEx(&WindowRect, dwStyle, NULL, dwExStyle); hWnd = CreateWindowEx(dwExStyle, L"OpenGL", (LPCWSTR)title, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN , 0, 0, WindowRect.right, WindowRect.bottom, NULL, NULL, hInstance, NULL); static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0,0,0,0,0,0, 0, 0, 0, 0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0,0,0 }; hDC = GetDC(hWnd); PixelFormat = ChoosePixelFormat(hDC, &pfd); SetPixelFormat(hDC, PixelFormat, &pfd); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); SetFocus(hWnd); //调用opemGL API Reshape(width, height); init(); return TRUE; }
void Window::InitializeWindows(int& screenWidth, int& screenHeight, LPCWSTR title) { WNDCLASSEX wc; DEVMODE dmScreenSettings; int posX, posY; //get external pointer to this object ApplicationHandle = this; //get instance of this application m_hinstance = GetModuleHandle(NULL); //give the application a name m_applicationName = title; //setup the windows class with the 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 fullscreen or not if (FULL_SCREEN) { //set the screen to the maximum size of the desktop 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 display settings to fullscreen ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN); //set the window position posX = posY = 0; } else { //set to a 800x600 resolution screenWidth = WINDOWED_WIDTH; screenHeight = WINDOWED_HEIGTH; //place the window in the middle of the screen posX = (GetSystemMetrics(SM_CXSCREEN) - screenWidth) /2; posY = (GetSystemMetrics(SM_CYSCREEN) - screenHeight) /2; } //create the window and apply the settings 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); m_screenwidth = screenWidth; m_screenheight = screenHeight; //bring the window up and set it as main focus ShowWindow(m_hwnd, SW_SHOW); SetForegroundWindow(m_hwnd); SetFocus(m_hwnd); //Hide the mouse cursor ShowCursor(SHOW_CURSOR); return; }
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { PMAIN_WND_INFO Info; LRESULT Ret = 0; /* Get the window context */ Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (Info == NULL && msg != WM_CREATE) { goto HandleDefaultMessage; } switch(msg) { case WM_CREATE: { Info = (PMAIN_WND_INFO)(((LPCREATESTRUCT)lParam)->lpCreateParams); /* Initialize the main window context */ Info->hMainWnd = hwnd; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)Info); if (!InitMainWnd(Info)) SendMessage(hwnd, WM_CLOSE, 0, 0); /* Show the window */ ShowWindow(hwnd, Info->nCmdShow); } break; case WM_SETFOCUS: { if (Info->hTreeView != NULL) SetFocus(Info->hTreeView); } break; case WM_SIZE: { MainWndResize(Info, LOWORD(lParam), HIWORD(lParam)); } break; case WM_NOTIFY: { Ret = OnNotify(Info, lParam); } break; case WM_CONTEXTMENU: { OnContext(Info, lParam); } break; case WM_COMMAND: { MainWndCommand(Info, LOWORD(wParam), (HWND)lParam); goto HandleDefaultMessage; } case WM_MENUSELECT: { if (Info->hStatus != NULL) { if (!MainWndMenuHint(Info, LOWORD(wParam), MainMenuHintTable, sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]), IDS_HINT_BLANK)) { MainWndMenuHint(Info, LOWORD(wParam), SystemMenuHintTable, sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]), IDS_HINT_BLANK); } } } break; case WM_ENTERMENULOOP: { Info->InMenuLoop = TRUE; UpdateMainStatusBar(Info); break; } case WM_EXITMENULOOP: { Info->InMenuLoop = FALSE; UpdateMainStatusBar(Info); break; } case WM_CLOSE: { FreeDeviceStrings(Info->hTreeView); DestroyMenu(Info->hShortcutMenu); DestroyWindow(hwnd); } break; case WM_DESTROY: { HeapFree(ProcessHeap, 0, Info); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); /* Break the message queue loop */ PostQuitMessage(0); } break; default: { HandleDefaultMessage: Ret = DefWindowProc(hwnd, msg, wParam, lParam); } break; } return Ret; }
/** * \author Darryn Campbell (DCC, JRQ768) * \date February 2010 (Initial Creation, DCC) */ void HideSIPButton() { HWND hg_sipbut = FindWindow(L"MS_SIPBUTTON", NULL); if (hg_sipbut) ShowWindow(hg_sipbut, SW_HIDE); }
// Windows main function INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) { // Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), LoadIcon( NULL, IDI_APPLICATION ), LoadCursor( NULL, IDC_ARROW ), NULL, NULL, "PostProcess", NULL }; RegisterClassEx( &wc ); // Create the application's window HWND hWnd = CreateWindow( "PostProcess", "CO3303: Full Screen Post Processing", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 960, NULL, NULL, wc.hInstance, NULL ); // Initialize Direct3D, the scene and post-processing if (gen::D3DSetup( hWnd ) && gen::SceneSetup() && gen::PostProcessSetup()) { // Show the window ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); // Reset the timer for a timed game loop gen::Timer.Reset(); // Enter the message loop MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message != WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // Render and update the scene - using variable timing float updateTime = gen::Timer.GetLapTime(); gen::RenderScene( updateTime ); gen::UpdateScene( updateTime ); // Toggle fullscreen / windowed if (gen::KeyHit( gen::Key_F1 )) { if (!gen::ResetDevice( hWnd, true )) { DestroyWindow( hWnd ); } } // Quit on escape if (gen::KeyHit( gen::Key_Escape )) { DestroyWindow( hWnd ); } } } } gen::PostProcessShutdown(); gen::SceneShutdown(); gen::D3DShutdown(); UnregisterClass( "PostProcess", wc.hInstance ); return 0; }
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { int i, size; char *selected_language = NULL; static HFONT font; switch (uMsg) { case WM_INITDIALOG: // add languages for (i = visible_langs_num - 1; i >= 0; i--) { int cbi; cbi = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM) langs[i].name); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, cbi, (LPARAM) langs[i].id); // remember selected language if (!lstrcmp(langs[i].id, getuservariable(INST_LANG))) { selected_language = langs[i].name; } } // select the current language if (selected_language) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) selected_language); else SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, 0, 0); // set texts SetDlgItemText(hwndDlg, IDC_TEXT, g_wndtext); SetWindowText(hwndDlg, g_wndtitle); SendDlgItemMessage(hwndDlg, IDC_APPICON, STM_SETICON, (LPARAM)LoadIcon(GetModuleHandle(0),MAKEINTRESOURCE(103)), 0); // set font if (dofont && !popstring(temp)) { size = myatou(temp); if (!popstring(temp)) { LOGFONT f = {0,}; if (lstrcmp(temp, "MS Shell Dlg")) { f.lfHeight = -MulDiv(size, GetDeviceCaps(GetDC(hwndDlg), LOGPIXELSY), 72); lstrcpy(f.lfFaceName, temp); font = CreateFontIndirect(&f); SendMessage(hwndDlg, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDOK, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDCANCEL, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, WM_SETFONT, (WPARAM)font, 1); SendDlgItemMessage(hwndDlg, IDC_TEXT, WM_SETFONT, (WPARAM)font, 1); } } } // show window ShowWindow(hwndDlg, SW_SHOW); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: // push result on the stack i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0); i = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0); if (i != CB_ERR && i) { pushstring((char *) i); } else { // ?! pushstring("cancel"); } // end dialog EndDialog(hwndDlg, 0); break; case IDCANCEL: // push "cancel" on the stack pushstring("cancel"); // end dialog EndDialog(hwndDlg, 0); break; } break; case WM_DESTROY: // clean up if (font) DeleteObject(font); break; default: return FALSE; // message not processed } return TRUE; // message processed }
OpenGLWindow::OpenGLWindow(const char* aTitle, int aWidth, int aHeight, bool aIsFullScreen) : m_WindowHandle(NULL), m_WindowDeviceContext(NULL), m_OpenGLContext(NULL), m_IsFullScreen(aIsFullScreen) { //Pass in the window title, and register the window class. registerWindowClass(aTitle); // RECT WindowRect; WindowRect.top = WindowRect.left = 0; WindowRect.right = aWidth; WindowRect.bottom = aHeight; //Window Extended Style DWORD extendedWindowStyle = 0; //Windows Style DWORD windowStyle = 0; //Do we hide the cursor? ShowCursor(WINDOW_SHOW_MOUSE_CURSOR); if(m_IsFullScreen == true) { DEVMODE dmScreenSettings; memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = aWidth; dmScreenSettings.dmPelsHeight = aHeight; dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; //Change the display settings to fullscreen. On error, throw an exception. if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { throw Win32Exception("Unable to swith to fullscreen mode"); } extendedWindowStyle = WS_EX_APPWINDOW; windowStyle = WS_POPUP; } else { extendedWindowStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; windowStyle = WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_MINIMIZEBOX; } //Adjust the window to the true requested size AdjustWindowRectEx(&WindowRect, windowStyle, false, extendedWindowStyle); //Now create the OpenGL window m_WindowHandle = CreateWindowEx(extendedWindowStyle, aTitle, aTitle, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | windowStyle, WINDOW_DEFAULT_X, WINDOW_DEFAULT_Y, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, GetModuleHandle(NULL), this); // if(m_WindowHandle == NULL) { throw Win32Exception("Cannot create the main window"); } // createOpenGLContext(); //Show the newly created window ShowWindow(m_WindowHandle, SW_SHOW); // Call OnSize manually because in fullscreen mode it will be // called only when the window is created (which is too early // because OpenGL is not initialized yet). resize(aWidth, aHeight); // m_LastMouseX = -1; m_LastMouseY = -1; }
INT_PTR CALLBACK DotNetAsmPageDlgProc( __in HWND hwndDlg, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam ) { LPPROPSHEETPAGE propSheetPage; PPH_PROCESS_PROPPAGECONTEXT propPageContext; PPH_PROCESS_ITEM processItem; PASMPAGE_CONTEXT context; if (PhPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext, &processItem)) { context = propPageContext->Context; } else { return FALSE; } switch (uMsg) { case WM_INITDIALOG: { ULONG result = 0; PPH_STRING settings; LARGE_INTEGER timeout; HWND tnHandle; context = PhAllocate(sizeof(ASMPAGE_CONTEXT)); memset(context, 0, sizeof(ASMPAGE_CONTEXT)); propPageContext->Context = context; context->WindowHandle = hwndDlg; context->ProcessItem = processItem; context->ClrVersions = 0; PhGetProcessIsDotNetEx(processItem->ProcessId, NULL, 0, NULL, &context->ClrVersions); context->NodeList = PhCreateList(64); context->NodeRootList = PhCreateList(2); tnHandle = GetDlgItem(hwndDlg, IDC_LIST); context->TnHandle = tnHandle; TreeNew_SetRedraw(tnHandle, FALSE); TreeNew_SetCallback(tnHandle, DotNetAsmTreeNewCallback, context); TreeNew_SetExtendedFlags(tnHandle, TN_FLAG_ITEM_DRAG_SELECT, TN_FLAG_ITEM_DRAG_SELECT); PhSetControlTheme(tnHandle, L"explorer"); SendMessage(TreeNew_GetTooltips(tnHandle), TTM_SETMAXTIPWIDTH, 0, MAXSHORT); PhAddTreeNewColumn(tnHandle, DNATNC_STRUCTURE, TRUE, L"Structure", 240, PH_ALIGN_LEFT, -2, 0); PhAddTreeNewColumn(tnHandle, DNATNC_ID, TRUE, L"ID", 50, PH_ALIGN_RIGHT, 0, DT_RIGHT); PhAddTreeNewColumn(tnHandle, DNATNC_FLAGS, TRUE, L"Flags", 120, PH_ALIGN_LEFT, 1, 0); PhAddTreeNewColumn(tnHandle, DNATNC_PATH, TRUE, L"Path", 600, PH_ALIGN_LEFT, 2, 0); // don't use path ellipsis - the user already has the base file name PhAddTreeNewColumn(tnHandle, DNATNC_NATIVEPATH, TRUE, L"Native Image Path", 600, PH_ALIGN_LEFT, 3, 0); settings = PhGetStringSetting(SETTING_NAME_ASM_TREE_LIST_COLUMNS); PhCmLoadSettings(tnHandle, &settings->sr); PhDereferenceObject(settings); SetCursor(LoadCursor(NULL, IDC_WAIT)); if (context->ClrVersions & PH_CLR_VERSION_1_0) { AddFakeClrNode(context, L"CLR v1.0.3705"); // what PE displays } if (context->ClrVersions & PH_CLR_VERSION_1_1) { AddFakeClrNode(context, L"CLR v1.1.4322"); } timeout.QuadPart = -10 * PH_TIMEOUT_SEC; if (context->ClrVersions & PH_CLR_VERSION_2_0) { context->ClrV2Node = AddFakeClrNode(context, L"CLR v2.0.50727"); result = UpdateDotNetTraceInfoWithTimeout(context, TRUE, &timeout); } if (context->ClrVersions & PH_CLR_VERSION_4_ABOVE) { result = UpdateDotNetTraceInfoWithTimeout(context, FALSE, &timeout); } TreeNew_NodesStructured(tnHandle); TreeNew_SetRedraw(tnHandle, TRUE); SetCursor(LoadCursor(NULL, IDC_ARROW)); if (result != 0) { ShowWindow(tnHandle, SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ERROR), SW_SHOW); if (result == ERROR_ACCESS_DENIED) { SetDlgItemText(hwndDlg, IDC_ERROR, L"Unable to start the event tracing session. Make sure Process Hacker is running with administrative privileges."); } else { SetDlgItemText(hwndDlg, IDC_ERROR, PhaConcatStrings2(L"Unable to start the event tracing session: %s", PhGetStringOrDefault(PhGetWin32Message(result), L"Unknown error"))->Buffer); } } } break; case WM_DESTROY: { PPH_STRING settings; ULONG i; settings = PhCmSaveSettings(context->TnHandle); PhSetStringSetting2(SETTING_NAME_ASM_TREE_LIST_COLUMNS, &settings->sr); PhDereferenceObject(settings); for (i = 0; i < context->NodeList->Count; i++) DestroyNode(context->NodeList->Items[i]); PhDereferenceObject(context->NodeList); PhDereferenceObject(context->NodeRootList); PhFree(context); PhPropPageDlgProcDestroy(hwndDlg); } break; case WM_SHOWWINDOW: { PPH_LAYOUT_ITEM dialogItem; if (dialogItem = PhBeginPropPageLayout(hwndDlg, propPageContext)) { PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_LIST), dialogItem, PH_ANCHOR_ALL); PhAddPropPageLayoutItem(hwndDlg, GetDlgItem(hwndDlg, IDC_ERROR), dialogItem, PH_ANCHOR_LEFT | PH_ANCHOR_TOP | PH_ANCHOR_RIGHT | PH_LAYOUT_FORCE_INVALIDATE); PhEndPropPageLayout(hwndDlg, propPageContext); } } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case ID_COPY: { PPH_STRING text; text = PhGetTreeNewText(context->TnHandle, 0); PhSetClipboardStringEx(context->TnHandle, text->Buffer, text->Length); PhDereferenceObject(text); } break; } } break; } return FALSE; }
void ConfigureCheat (void) { if (!cartOpen) return; OSStatus err; IBNibRef nibRef; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { err = CreateWindowFromNib(nibRef, CFSTR("CheatEntry"), &wRef); if (err == noErr) { DataBrowserCallbacks callbacks; EventHandlerRef eref; EventHandlerUPP eUPP; EventTypeSpec events[] = { { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus }, { kEventClassWindow, kEventWindowClose } }; HIViewRef ctl, root; HIViewID cid; root = HIViewGetRoot(wRef); cid.id = 0; cid.signature = kDataBrowser; HIViewFindByID(root, cid, &dbRef); #ifdef MAC_PANTHER_SUPPORT if (systemVersion < 0x1040) { HISize minSize; Rect rct; GetWindowBounds(wRef, kWindowContentRgn, &rct); minSize.width = (float) (rct.right - rct.left); minSize.height = (float) (rct.bottom - rct.top ); err = SetWindowResizeLimits(wRef, &minSize, NULL); } #endif callbacks.version = kDataBrowserLatestCallbacks; err = InitDataBrowserCallbacks(&callbacks); callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DBClientDataCallback); callbacks.u.v1.itemCompareCallback = NewDataBrowserItemCompareUPP(DBCompareCallBack); callbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP(DBItemNotificationCallBack); err = SetDataBrowserCallbacks(dbRef, &callbacks); if (systemVersion >= 0x1040) err = DataBrowserChangeAttributes(dbRef, kDataBrowserAttributeListViewAlternatingRowColors, kDataBrowserAttributeNone); InitCheatItems(); ImportCheatItems(); DataBrowserItemID *id; id = new DataBrowserItemID[MAX_CHEATS]; if (!id) QuitWithFatalError(0, "cheat 01"); numofcheats = 0; for (unsigned int i = 0; i < MAX_CHEATS; i++) { if (citem[i].valid) { id[numofcheats] = citem[i].id; numofcheats++; } } if (numofcheats) err = AddDataBrowserItems(dbRef, kDataBrowserNoItem, numofcheats, id, kDataBrowserItemNoProperty); delete [] id; cid.signature = kNewButton; HIViewFindByID(root, cid, &ctl); if (numofcheats == MAX_CHEATS) err = DeactivateControl(ctl); else err = ActivateControl(ctl); cid.signature = kAllButton; HIViewFindByID(root, cid, &ctl); if (numofcheats == 0) err = DeactivateControl(ctl); else err = ActivateControl(ctl); cid.signature = kDelButton; HIViewFindByID(root, cid, &ctl); err = DeactivateControl(ctl); eUPP = NewEventHandlerUPP(CheatEventHandler); err = InstallWindowEventHandler(wRef, eUPP, GetEventTypeCount(events), events, (void *) wRef, &eref); err = SetKeyboardFocus(wRef, dbRef, kControlFocusNextPart); MoveWindowPosition(wRef, kWindowCheatEntry, true); ShowWindow(wRef); err = RunAppModalLoopForWindow(wRef); HideWindow(wRef); SaveWindowPosition(wRef, kWindowCheatEntry); err = RemoveEventHandler(eref); DisposeEventHandlerUPP(eUPP); DisposeDataBrowserItemNotificationUPP(callbacks.u.v1.itemNotificationCallback); DisposeDataBrowserItemCompareUPP(callbacks.u.v1.itemCompareCallback); DisposeDataBrowserItemDataUPP(callbacks.u.v1.itemDataCallback); CFRelease(wRef); DetachCheatItems(); } DisposeNibReference(nibRef); } }
void CMainWindow::cmdMinimize () { ShowWindow(SW_MINIMIZE); }