bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) { bool bRet = false; do { CC_BREAK_IF(m_hWnd); HINSTANCE hInstance = GetModuleHandle( NULL ); WNDCLASS wc; // Windows Class Structure // Redraw On Size, And Own DC For Window. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = _WindowProc; // 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 = kWindowClassName; // Set The Class Name CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError()); // center window position RECT rcDesktop; GetWindowRect(GetDesktopWindow(), &rcDesktop); // create window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window kWindowClassName, // Class Name pTitle, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position 0, // Window Width 0, // Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL ); CC_BREAK_IF(! m_hWnd); m_eInitOrientation = CCDirector::sharedDirector()->getDeviceOrientation(); m_bOrientationInitVertical = (CCDeviceOrientationPortrait == m_eInitOrientation || kCCDeviceOrientationPortraitUpsideDown == m_eInitOrientation) ? true : false; m_tSizeInPoints.cx = w; m_tSizeInPoints.cy = h; resize(w, h); // init egl m_pEGL = CCEGL::create(this); if (! m_pEGL) { DestroyWindow(m_hWnd); m_hWnd = NULL; break; } s_pMainWindow = this; bRet = true; } while (0); return bRet; }
SDL_bool CommonInit(CommonState * state) { int i, j, m, n; SDL_DisplayMode fullscreen_mode; if (state->flags & SDL_INIT_VIDEO) { if (state->verbose & VERBOSE_VIDEO) { n = SDL_GetNumVideoDrivers(); if (n == 0) { fprintf(stderr, "No built-in video drivers\n"); } else { fprintf(stderr, "Built-in video drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { fprintf(stderr, ","); } fprintf(stderr, " %s", SDL_GetVideoDriver(i)); } fprintf(stderr, "\n"); } } if (SDL_VideoInit(state->videodriver, 0) < 0) { fprintf(stderr, "Couldn't initialize video driver: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->verbose & VERBOSE_VIDEO) { fprintf(stderr, "Video driver: %s\n", SDL_GetCurrentVideoDriver()); } /* Upload GL settings */ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, state->gl_red_size); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, state->gl_green_size); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, state->gl_blue_size); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, state->gl_alpha_size); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, state->gl_double_buffer); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, state->gl_buffer_size); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, state->gl_depth_size); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, state->gl_stencil_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, state->gl_accum_red_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, state->gl_accum_green_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size); SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples); if (state->gl_accelerated >= 0) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, state->gl_accelerated); } SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version); if (state->verbose & VERBOSE_MODES) { SDL_DisplayMode mode; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; n = SDL_GetNumVideoDisplays(); fprintf(stderr, "Number of displays: %d\n", n); for (i = 0; i < n; ++i) { fprintf(stderr, "Display %d:\n", i); SDL_SelectVideoDisplay(i); SDL_GetDesktopDisplayMode(&mode); SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); fprintf(stderr, " Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n", mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask); fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask); fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask); if (Amask) fprintf(stderr, " Alpha Mask = 0x%.8x\n", Amask); } /* Print available fullscreen video modes */ m = SDL_GetNumDisplayModes(); if (m == 0) { fprintf(stderr, "No available fullscreen video modes\n"); } else { fprintf(stderr, " Fullscreen video modes:\n"); for (j = 0; j < m; ++j) { SDL_GetDisplayMode(j, &mode); SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); fprintf(stderr, " Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n", j, mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask); fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask); fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask); if (Amask) fprintf(stderr, " Alpha Mask = 0x%.8x\n", Amask); } } } } } SDL_SelectVideoDisplay(state->display); if (state->verbose & VERBOSE_RENDER) { SDL_RendererInfo info; n = SDL_GetNumRenderDrivers(); if (n == 0) { fprintf(stderr, "No built-in render drivers\n"); } else { fprintf(stderr, "Built-in render drivers:\n"); for (i = 0; i < n; ++i) { SDL_GetRenderDriverInfo(i, &info); PrintRenderer(&info); } } } SDL_zero(fullscreen_mode); switch (state->depth) { case 8: fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8; break; case 15: fullscreen_mode.format = SDL_PIXELFORMAT_RGB555; break; case 16: fullscreen_mode.format = SDL_PIXELFORMAT_RGB565; break; case 24: fullscreen_mode.format = SDL_PIXELFORMAT_RGB24; break; default: fullscreen_mode.format = SDL_PIXELFORMAT_RGB888; break; } fullscreen_mode.refresh_rate = state->refresh_rate; state->windows = (SDL_Window **) SDL_malloc(state->num_windows * sizeof(*state->windows)); if (!state->windows) { fprintf(stderr, "Out of memory!\n"); return SDL_FALSE; } for (i = 0; i < state->num_windows; ++i) { char title[1024]; if (state->num_windows > 1) { SDL_snprintf(title, SDL_arraysize(title), "%s %d", state->window_title, i + 1); } else { SDL_strlcpy(title, state->window_title, SDL_arraysize(title)); } state->windows[i] = SDL_CreateWindow(title, state->window_x, state->window_y, state->window_w, state->window_h, state->window_flags); if (!state->windows[i]) { fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) { fprintf(stderr, "Can't set up fullscreen display mode: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->window_icon) { SDL_Surface *icon = LoadIcon(state->window_icon); if (icon) { SDL_SetWindowIcon(state->windows[i], icon); SDL_FreeSurface(icon); } } SDL_ShowWindow(state->windows[i]); if (!state->skip_renderer && (state->renderdriver || !(state->window_flags & SDL_WINDOW_OPENGL))) { m = -1; if (state->renderdriver) { SDL_RendererInfo info; n = SDL_GetNumRenderDrivers(); for (j = 0; j < n; ++j) { SDL_GetRenderDriverInfo(j, &info); if (SDL_strcasecmp(info.name, state->renderdriver) == 0) { m = j; break; } } if (m == n) { fprintf(stderr, "Couldn't find render driver named %s", state->renderdriver); return SDL_FALSE; } } if (SDL_CreateRenderer (state->windows[i], m, state->render_flags) < 0) { fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->verbose & VERBOSE_RENDER) { SDL_RendererInfo info; fprintf(stderr, "Current renderer:\n"); SDL_GetRendererInfo(&info); PrintRenderer(&info); } } } SDL_SelectRenderer(state->windows[0]); } if (state->flags & SDL_INIT_AUDIO) { if (state->verbose & VERBOSE_AUDIO) { n = SDL_GetNumAudioDrivers(); if (n == 0) { fprintf(stderr, "No built-in audio drivers\n"); } else { fprintf(stderr, "Built-in audio drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { fprintf(stderr, ","); } fprintf(stderr, " %s", SDL_GetAudioDriver(i)); } fprintf(stderr, "\n"); } } if (SDL_AudioInit(state->audiodriver) < 0) { fprintf(stderr, "Couldn't initialize audio driver: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->verbose & VERBOSE_VIDEO) { fprintf(stderr, "Audio driver: %s\n", SDL_GetCurrentAudioDriver()); } if (SDL_OpenAudio(&state->audiospec, NULL) < 0) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); return SDL_FALSE; } } return SDL_TRUE; }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // graphics device context // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // save hinstance in global hinstance_app = hinstance; // register the window class if (!RegisterClassEx(&winclass)) return(0); // create the window if (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "DirectDraw 24-Bit Bitmap Loading", // title WS_POPUP | WS_VISIBLE, 0,0, // initial x,y SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parms return(0); // save main window handle main_window_handle = hwnd; // initialize game here Game_Init(); // enter main event loop while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // closedown game here Game_Shutdown(); // return to Windows like this return(msg.wParam); } // end WinMain
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: { CenterWindow(hDlg); hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); hBrush = CreateSolidBrush(RGB(240, 240, 240)); DisableVisualStylesFilters(hDlg); LPTREEFOLDER folder = GetCurrentFolder(); LPTREEFOLDER lpParent = NULL; LPCFILTER_ITEM g_lpFilterList = GetFilterList(); dwFilters = 0; if (folder != NULL) { char tmp[80]; win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str()); Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1); // Mask out non filter flags dwFilters = folder->m_dwFlags & F_MASK; // Display current folder name in dialog titlebar snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle); win_set_window_text_utf8(hDlg, tmp); if (GetFilterInherit()) { lpParent = GetFolder(folder->m_nParent); bool bShowExplanation = false; if (lpParent) { std::string strText; /* Check the Parent Filters and inherit them on child, * No need to promote all games to parent folder, works as is */ dwpFilters = lpParent->m_dwFlags & F_MASK; /*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/ if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_AVAILABLE) && !(dwFilters & F_AVAILABLE)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_AVAILABLE), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_HORIZONTAL) && !(dwFilters & F_HORIZONTAL)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_HORIZONTAL), strText.c_str()); bShowExplanation = true; } if ((dwpFilters & F_VERTICAL) && !(dwFilters & F_VERTICAL)) { /*Add a Specifier to the Checkbox to show it was inherited from the parent*/ strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL)); strText.append(" (*)"); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VERTICAL), strText.c_str()); bShowExplanation = true; } /*Do not or in the Values of the parent, so that the values of the folder still can be set*/ //dwFilters |= dwpFilters; } if(bShowExplanation) { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), true); } } else { ShowWindow(GetDlgItem(hDlg, IDC_INHERITED), false); } // Find the matching filter record if it exists lpFilterRecord = FindFilter(folder->m_nFolderId); // initialize and disable appropriate controls for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++) { DisableFilterControls(hDlg, lpFilterRecord, &g_lpFilterList[i], dwFilters); } } SetFocus(GetDlgItem(hDlg, IDC_FILTER_EDIT)); return false; } case WM_CTLCOLORDLG: return (LRESULT) hBrush; case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: hDC = (HDC)wParam; SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); return (LRESULT) hBrush; case WM_COMMAND: { WORD wID = GET_WM_COMMAND_ID(wParam, lParam); WORD wNotifyCode = GET_WM_COMMAND_CMD(wParam, lParam); LPTREEFOLDER folder = GetCurrentFolder(); LPCFILTER_ITEM g_lpFilterList = GetFilterList(); switch (wID) { case IDOK: dwFilters = 0; g_FilterText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT)); // see which buttons are checked for (int i = 0; g_lpFilterList[i].m_dwFilterType; i++) { if (Button_GetCheck(GetDlgItem(hDlg, g_lpFilterList[i].m_dwCtrlID))) dwFilters |= g_lpFilterList[i].m_dwFilterType; } // Mask out invalid filters dwFilters = ValidateFilters(lpFilterRecord, dwFilters); // Keep non filter flags folder->m_dwFlags &= ~F_MASK; // put in the set filters folder->m_dwFlags |= dwFilters; DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 1); return true; case IDCANCEL: DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); return true; default: // Handle unchecking mutually exclusive filters if (wNotifyCode == BN_CLICKED) EnableFilterExclusions(hDlg, wID); } break; } } return false; }
INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: { CenterWindow(hDlg); hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); hBrush = CreateSolidBrush(RGB(240, 240, 240)); if (IsWindowsSevenOrHigher()) SendMessage(GetDlgItem(hDlg, IDC_CUSTOM_TREE), TVM_SETEXTENDEDSTYLE, TVS_EX_DOUBLEBUFFER, TVS_EX_DOUBLEBUFFER); SetWindowTheme(GetDlgItem(hDlg, IDC_CUSTOM_TREE), L"Explorer", NULL); TREEFOLDER **folders; int num_folders = 0; TVINSERTSTRUCT tvis; TVITEM tvi; bool first_entry = true; HIMAGELIST treeview_icons = GetTreeViewIconList(); // current game passed in using DialogBoxParam() driver_index = lParam; (void)TreeView_SetImageList(GetDlgItem(hDlg, IDC_CUSTOM_TREE), treeview_icons, LVSIL_NORMAL); GetFolders(&folders, &num_folders); // insert custom folders into our tree view for (int i = 0; i < num_folders; i++) { if (folders[i]->m_dwFlags & F_CUSTOM) { HTREEITEM hti; if (folders[i]->m_nParent == -1) { memset(&tvi, 0, sizeof(TVITEM)); tvis.hParent = TVI_ROOT; tvis.hInsertAfter = TVI_SORT; tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.pszText = folders[i]->m_lptTitle; tvi.lParam = (LPARAM)folders[i]; tvi.iImage = GetTreeViewIconIndex(folders[i]->m_nIconId); tvi.iSelectedImage = 0; tvis.item = tvi; hti = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis); /* look for children of this custom folder */ for (int jj = 0; jj < num_folders; jj++) { if (folders[jj]->m_nParent == i) { HTREEITEM hti_child; tvis.hParent = hti; tvis.hInsertAfter = TVI_SORT; tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.pszText = folders[jj]->m_lptTitle; tvi.lParam = (LPARAM)folders[jj]; tvi.iImage = GetTreeViewIconIndex(folders[jj]->m_nIconId); tvi.iSelectedImage = 0; tvis.item = tvi; hti_child = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis); if (folders[jj] == default_selection) (void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), hti_child); } } /*TreeView_Expand(GetDlgItem(hDlg,IDC_CUSTOM_TREE),hti,TVE_EXPAND);*/ if (first_entry || folders[i] == default_selection) { (void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE),hti); first_entry = false; } } } } win_set_window_text_utf8(GetDlgItem(hDlg, IDC_CUSTOMFILE_GAME), GetDriverGameTitle(driver_index)); return true; } case WM_CTLCOLORDLG: return (LRESULT) hBrush; case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: hDC = (HDC)wParam; SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); return (LRESULT) hBrush; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: { TVITEM tvi; tvi.hItem = TreeView_GetSelection(GetDlgItem(hDlg, IDC_CUSTOM_TREE)); tvi.mask = TVIF_PARAM; if (TreeView_GetItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE),&tvi) == true) { /* should look for New... */ default_selection = (LPTREEFOLDER)tvi.lParam; /* start here next time */ AddToCustomFolder((LPTREEFOLDER)tvi.lParam, driver_index); } DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); return true; } case IDCANCEL: DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); return true; } break; } return false; }
void NetGseEx::DrawOfficeASE(HINSTANCE hinst, HWND hwnd, HDC hdc, ActorRequest* ActReq) { static BOOL Init = TRUE; if (Init == TRUE) { Init = FALSE; IconHndl[1] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1)); IconHndl[2] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2)); IconHndl[3] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON3)); IconHndl[4] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON4)); IconHndl[5] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON5)); IconHndl[6] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON6)); IconHndl[7] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON7)); IconHndl[8] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON8)); IconHndl[9] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON9)); IconHndl[10] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON10)); IconHndl[11] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON11)); IconHndl[12] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON12)); IconHndl[13] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON13)); IconHndl[14] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON14)); IconHndl[15] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON15)); IconHndl[16] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON16)); IconHndl[17] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON17)); IconHndl[18] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON18)); IconHndl[19] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON19)); IconHndl[20] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON20)); IconHndl[21] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON21)); IconHndl[22] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON22)); IconHndl[23] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON23)); IconHndl[24] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON24)); IconHndl[25] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON25)); IconHndl[26] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON26)); IconHndl[27] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON27)); IconHndl[28] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON28)); IconHndl[29] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON29)); IconHndl[30] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON30)); IconHndl[31] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON31)); IconHndl[32] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON32)); IconHndl[33] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON33)); IconHndl[34] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON34)); IconHndl[35] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON35)); IconHndl[36] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON36)); IconHndl[37] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON37)); IconHndl[38] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON38)); IconHndl[39] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON39)); IconHndl[40] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON40)); IconHndl[41] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON41)); IconHndl[42] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON42)); IconHndl[43] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON43)); IconHndl[44] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON44)); IconHndl[45] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON45)); IconHndl[46] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON46)); IconHndl[47] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON47)); IconHndl[48] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON48)); IconHndl[50] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON50), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[51] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON51), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[52] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON52), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[53] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON53), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[54] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON54), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[55] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON55), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[56] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON56), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[60] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON60), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[61] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON61), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[62] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON62), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); IconHndl[71] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON71)); IconHndl[72] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON72)); IconHndl[73] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON73)); } int r = ActReq->GetRequest(); int c = ActReq->GetActorId(); int bottom = ActReq->GetIntParam1(); int top = ActReq->GetIntParam2(); int right = ActReq->GetIntParam3(); int left = ActReq->GetIntParam4(); TCHAR* NameBuf = ActReq->GetStringParam1(); StkFont* Fon = StkFont::GetInstance(); if (r < 0) { RECT rt; HBRUSH b1 = CreateSolidBrush(RGB(255, 255, 255)); SelectObject(hdc, b1); rt.right = right; rt.left = left; rt.top = top; rt.bottom = bottom; FillRect(hdc, &rt, b1); DeleteObject(b1); r *= -1; } int SizeW = right - left; int SizeH = bottom - top; DrawIconEx(hdc, left, top, IconHndl[r], SizeW, SizeH, NULL, NULL, DI_NORMAL); Fon->ArialFontSmallTextOut(hdc, left + SizeW / 2, bottom + 5, NameBuf, RGB(255, 255, 255), TRUE); }
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 BOOL CALLBACK DialogProcUninstall(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HICON hIcon; int x; TCHAR tmpbuf[MAX_PATH]; if (uMsg == WM_DESTROY && hIcon) { DeleteObject(hIcon); hIcon=0; } if (uMsg == WM_INITDIALOG || uMsg == WM_USER+1) { struct { LPTSTR id; WNDPROC proc; LPTSTR s; } windows[2]= { {MAKEINTRESOURCE(IDD_UNINST),UninstProc,""}, {MAKEINTRESOURCE(IDD_INSTFILES),InstProc,""}, }; int messages[2] = { JAVAWS_MESSAGE_CONFIRM, JAVAWS_MESSAGE_UNINSTFILES }; for (x=0; x<2; x++) { GETRESOURCE(tmpbuf, messages[x]); windows[x].s = (LPTSTR)GlobalAlloc(GMEM_FIXED, (_tcslen(tmpbuf) + 1) * sizeof(TCHAR)); _tcscpy(windows[x].s, tmpbuf); } if (uMsg == WM_INITDIALOG) { g_hwnd=hwndDlg; hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2)); SetClassLong(hwndDlg,GCL_HICON,(long)hIcon); EnableWindow(GetDlgItem(hwndDlg,IDC_BACK),0); } if (m_curwnd) DestroyWindow(m_curwnd); if (m_page < 0 || m_page > 1) { EndDialog(hwndDlg,0); } else { INT32 args[] = { (INT32)m_uninstheader->name, (INT32)windows[m_page].s }; m_curwnd=CreateDialog(g_hInstance,windows[m_page].id,hwndDlg,windows[m_page].proc); GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_UNINSTALL2, args); SetWindowText(hwndDlg,tmpbuf); } if (m_curwnd) { RECT r; GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r); ScreenToClient(hwndDlg,(LPPOINT)&r); SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); ShowWindow(m_curwnd,SW_SHOWNA); } } if (uMsg == WM_COMMAND) { int id=LOWORD(wParam); if (id == IDOK && m_curwnd) { m_page++; SendMessage(hwndDlg,WM_USER+1,0,0); } if (id == IDCANCEL) { EndDialog(hwndDlg,2); } } return 0; }
/* ** Sys_CreateConsole */ void Sys_CreateConsole( void ) { HDC hDC; WNDCLASS wc; RECT rect; const char *DEDCLASS = "Q3 WinConsole"; int nHeight; int swidth, sheight; int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX; memset( &wc, 0, sizeof( wc ) ); wc.style = 0; wc.lpfnWndProc = (WNDPROC) ConWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_wv.hInstance; wc.hIcon = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1)); wc.hCursor = LoadCursor (NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszMenuName = 0; wc.lpszClassName = DEDCLASS; if ( !RegisterClass (&wc) ) return; rect.left = 0; rect.right = 540; rect.top = 0; rect.bottom = 450; AdjustWindowRect( &rect, DEDSTYLE, FALSE ); hDC = GetDC( GetDesktopWindow() ); swidth = GetDeviceCaps( hDC, HORZRES ); sheight = GetDeviceCaps( hDC, VERTRES ); ReleaseDC( GetDesktopWindow(), hDC ); s_wcd.windowWidth = rect.right - rect.left + 1; s_wcd.windowHeight = rect.bottom - rect.top + 1; s_wcd.hWnd = CreateWindowEx( 0, DEDCLASS, CONSOLE_WINDOW_TITLE, DEDSTYLE, ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1, NULL, NULL, g_wv.hInstance, NULL ); if ( s_wcd.hWnd == NULL ) { return; } // // create fonts // hDC = GetDC( s_wcd.hWnd ); nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72); s_wcd.hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, "Courier New" ); ReleaseDC( s_wcd.hWnd, hDC ); // // create the input line // s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, 6, 400, 528, 20, s_wcd.hWnd, ( HMENU ) INPUT_ID, // child window ID g_wv.hInstance, NULL ); // // create the buttons // s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 5, 425, 72, 24, s_wcd.hWnd, ( HMENU ) COPY_ID, // child window ID g_wv.hInstance, NULL ); SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "copy" ); s_wcd.hwndButtonClear = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 82, 425, 72, 24, s_wcd.hWnd, ( HMENU ) CLEAR_ID, // child window ID g_wv.hInstance, NULL ); SendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) "clear" ); s_wcd.hwndButtonQuit = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 462, 425, 72, 24, s_wcd.hWnd, ( HMENU ) QUIT_ID, // child window ID g_wv.hInstance, NULL ); SendMessage( s_wcd.hwndButtonQuit, WM_SETTEXT, 0, ( LPARAM ) "quit" ); // // create the scrollbuffer // s_wcd.hwndBuffer = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY, 6, 40, 526, 354, s_wcd.hWnd, ( HMENU ) EDIT_ID, // child window ID g_wv.hInstance, NULL ); SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 ); s_wcd.SysInputLineWndProc = ( WNDPROC ) SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long ) InputLineWndProc ); SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 ); ShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT); UpdateWindow( s_wcd.hWnd ); SetForegroundWindow( s_wcd.hWnd ); SetFocus( s_wcd.hwndInputLine ); s_wcd.visLevel = 1; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; HACCEL hAccelTable; WNDCLASSEX wcex; #ifdef _DEBUG INIT_CRT_DEBUG_REPORT(); //_CrtSetBreakAlloc(290); #endif wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = MainWnd::WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_APIGATE); wcex.lpszClassName = MainWnd::szClassName; wcex.hIconSm = wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APIGATE)); if (!RegisterClassEx(&wcex)) { return -1; } g_hInstance = hInstance; //if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) // TRACE("AfxWinInit failed.\n"); s_hRichEdit = LoadLibrary(_T("RICHED20.DLL")); INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); // if (!AfxInitRichEdit2()) // TRACE("AfxInitRichEdit failed.\n"); g_api = new ApiMan(); g_svr = new SvrMan(); if (!g_mainwnd.Create(nCmdShow)) { goto _finish; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_APIGATE)); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } _finish: g_mainwnd.Destroy(); delete g_svr; delete g_api; FreeLibrary(s_hRichEdit); UnregisterClass(MainWnd::szClassName, hInstance); return 0;// (int)msg.wParam; }
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HICON hIcon; TCHAR tmpbuf[MAX_PATH]; if (uMsg == WM_DESTROY && hIcon) { DeleteObject(hIcon); hIcon=0; } if (uMsg == WM_INITDIALOG || uMsg == WM_USER+1) { int backenabled=0,iscp=1,islp=1, x; struct { LPTSTR id; WNDPROC proc; LPTSTR s; } windows[4]= { {MAKEINTRESOURCE(IDD_LICENSE),LicenseProc,""}, {MAKEINTRESOURCE(IDD_SELCOM),LicenseProc,""}, {MAKEINTRESOURCE(IDD_DIR),DirProc,""}, {MAKEINTRESOURCE(IDD_INSTFILES),InstProc,""}, }; int messages[4] = { JAVAWS_MESSAGE_LICENSE, JAVAWS_MESSAGE_INSTOPT, JAVAWS_MESSAGE_INSTDIR, JAVAWS_MESSAGE_INSTFILES }; for( x=0; x<4; x++) { GETRESOURCE(tmpbuf, messages[x]); windows[x].s = (LPTSTR)malloc((_tcslen(tmpbuf) + 1) * sizeof(TCHAR)); _tcscpy(windows[x].s, tmpbuf); } if (uMsg == WM_INITDIALOG) { g_hwnd=hwndDlg; hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2)); SetClassLong(hwndDlg,GCL_HICON,(long)hIcon); } if (m_curwnd) DestroyWindow(m_curwnd); if (!m_header->licensetext[0] || m_header->licensedata_offset==-1) islp=0; if (m_page==0 && !islp) m_page++; if (m_page==1 && autoinstall == 2) { /* skip the rest of the dialog because it's an autoinstall */ g_hwnd = NULL; EndDialog(hwndDlg,3); } if (m_header->num_sections < 2) iscp=0; { int id=LOWORD(wParam); if (uMsg==(WM_USER+1) && id==IDC_BACK) { if (m_page==1 && !iscp) m_page--; } else { if (m_page==1 && !iscp) m_page++; } } if (m_page==1&&islp) backenabled=1; if (m_page==2&&(islp||iscp)) backenabled=1; if (m_page < 0 || m_page > 3) { EndDialog(hwndDlg,0); } else { HWND hwnd; GETRESOURCE(tmpbuf,JAVAWS_BACK); SetDlgItemText(hwndDlg,IDC_BACK,tmpbuf); if (m_page==0) { GETRESOURCE(tmpbuf,JAVAWS_DECLINE); SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf); GETRESOURCE(tmpbuf,JAVAWS_ACCEPT); SetDlgItemText(hwndDlg,IDOK,tmpbuf); hwnd=GetDlgItem(hwndDlg, IDC_BACK); ShowWindow(hwnd,SW_HIDE); } else { GETRESOURCE(tmpbuf,JAVAWS_CANCEL); SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf); GETRESOURCE(tmpbuf,JAVAWS_NEXT); SetDlgItemText(hwndDlg,IDOK,tmpbuf); hwnd=GetDlgItem(hwndDlg, IDC_BACK); ShowWindow(hwnd,SW_SHOWNA); } { INT32 args[] = { (INT32)m_header->name, (INT32)windows[m_page].s }; m_curwnd=CreateDialog(g_hInstance,windows[m_page].id,hwndDlg,windows[m_page].proc); GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_SETUP2, args); SetWindowText(hwndDlg,tmpbuf); } } if (m_curwnd) { RECT r; GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r); ScreenToClient(hwndDlg,(LPPOINT)&r); SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); ShowWindow(m_curwnd,SW_SHOWNA); EnableWindow(GetDlgItem(hwndDlg,IDC_BACK),backenabled); } } if (uMsg == WM_COMMAND) { int id=LOWORD(wParam); if (id == IDOK && m_curwnd) { m_page++; SendMessage(hwndDlg,WM_USER+1,wParam,0); } if (id == IDC_BACK && m_curwnd && m_page>0) { m_page--; SendMessage(hwndDlg,WM_USER+1,wParam,0); } if (id == IDCANCEL ) { if (m_abort) { EndDialog(hwndDlg,2); } else { EndDialog(hwndDlg,1); } } } return 0; }
//============================================================================== // エントリーポイント //============================================================================== int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; winc.lpfnWndProc = WndProc; // ウィンドウプロシージャ winc.cbClsExtra = 0; winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL, IDI_APPLICATION); winc.hCursor = LoadCursor(NULL, IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = CLASS_NAME; // ウィンドウクラス登録 if(RegisterClass(&winc) == false) { return 1; } // ウィンドウ作成 hwnd = CreateWindow( CLASS_NAME, CLASS_NAME, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, SCREEN_WIDTH + GetSystemMetrics(SM_CXFRAME) * 2, SCREEN_HEIGHT + GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), NULL, NULL, hInstance, NULL); if(hwnd == NULL) { return 1; } // Vulkan初期化 if(initVulkan(hInstance, hwnd) == false) { return 1; } // ウィンドウ表示 ShowWindow(hwnd, nCmdShow); FPSCounter fpsCounter; // FPSカウンター // メッセージループ do { fpsCounter.beginCount(); if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // メイン Render(); } fpsCounter.endCount(); std::string windowTitle = std::string(APPLICATION_NAME) + " - " + std::to_string(fpsCounter.getLastFPS()) + " FPS"; SetWindowText(hwnd, windowTitle.c_str()); } while(msg.message != WM_QUIT); // Vulkan破棄 destroyVulkan(); // 登録したクラスを解除 UnregisterClass(CLASS_NAME, hInstance); return 0; }
/** make the main window **/ HWND createMainWin(HINSTANCE hThisInstance, int sizeX, int sizeY){ /** declare a class name. Why? Because. **/ TCHAR szClassName[ ] = _T("Student Project"); /** declare the main window handle **/ HWND hwnd = NULL; /** declare data structure object variable for the window class **/ WNDCLASSEX wincl; /** initialize the window structure **/ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; // This function is called by windows wincl.style = CS_DBLCLKS; // Catch double-clicks wincl.cbSize = sizeof (WNDCLASSEX); /** use default icon and mouse-pointer **/ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); /** no menu **/ wincl.lpszMenuName = NULL; /** no extra bytes after the window class structure or the window instance */ wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; /** add a custom background color */ wincl.hbrBackground = CreateSolidBrush(RGB(255, 255, 255)); /** Register the window class, if it fails quit the program */ if(!RegisterClassEx(&wincl)) return 0; /** the class is registered, let's create the programs main window */ hwnd = CreateWindowEx( 0, // extended possibilities for variation szClassName, // Class name _T(" WinBreakoutC++ "), // Title Text WS_OVERLAPPEDWINDOW, // default window style CW_USEDEFAULT, // windows decides the position CW_USEDEFAULT, // where the window ends up on the screen sizeX, // the window width sizeY, // and height in pixels HWND_DESKTOP, // the window is a child-window to desktop NULL, // no menu hThisInstance, // the program instance handle NULL // no window creation data ); /** if window creation successful return the main window handle any work in the window will need this handle **/ if(hwnd) return hwnd; /** if we get this far we have failed to create a window for our program, returning 0 will cause a message to the user and then quit the process. **/ return 0; }
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR command_line, int nCmdShow) { MSG msg; WNDCLASS wndclass; HANDLE hAccel; # ifdef THREAD_LOCAL_ALLOC GC_INIT(); /* Required if GC is built with THREAD_LOCAL_ALLOC */ /* Always safe, but this is used as a GC test. */ # endif if (!hPrevInstance) { wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = DLGWINDOWEXTRA; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon (hInstance, szAppName); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = TEXT("DE"); wndclass.lpszClassName = szAppName; if (RegisterClass (&wndclass) == 0) { char buf[50]; sprintf(buf, "RegisterClass: error code: 0x%X", (unsigned)GetLastError()); de_error(buf); return(0); } } /* Empirically, the command line does not include the command name ... if (command_line != 0) { while (isspace(*command_line)) command_line++; while (*command_line != 0 && !isspace(*command_line)) command_line++; while (isspace(*command_line)) command_line++; } */ if (command_line == 0 || *command_line == 0) { de_error("File name argument required"); return( 0 ); } else { char *p = command_line; while (*p != 0 && !isspace(*(unsigned char *)p)) p++; arg_file_name = CORD_to_char_star( CORD_substr(command_line, 0, p - command_line)); } hwnd = CreateWindow (szAppName, TEXT("Demonstration Editor"), WS_OVERLAPPEDWINDOW | WS_CAPTION, /* Window style */ CW_USEDEFAULT, 0, /* default pos. */ CW_USEDEFAULT, 0, /* default width, height */ NULL, /* No parent */ NULL, /* Window class menu */ hInstance, NULL); if (hwnd == NULL) { char buf[50]; sprintf(buf, "CreateWindow: error code: 0x%X", (unsigned)GetLastError()); de_error(buf); return(0); } ShowWindow (hwnd, nCmdShow); hAccel = LoadAccelerators( hInstance, szAppName ); while (GetMessage (&msg, NULL, 0, 0)) { if( !TranslateAccelerator( hwnd, hAccel, &msg ) ) { TranslateMessage (&msg); DispatchMessage (&msg); } } return msg.wParam; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char const * const className = "3DClass"; WNDCLASSEX windowClass; windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WindowProc; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = hInstance; windowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); windowClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); windowClass.lpszMenuName = NULL; windowClass.lpszClassName = className; windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); RegisterClassEx(&windowClass); DWORD dwExStyle; DWORD dwStyle; dwStyle = // WS_CLIPCHILDREN | // WS_CLIPSIBLINGS | // WS_SIZEBOX | // WS_CAPTION | WS_SYSMENU | // show "x" in top right corner to close window. WS_OVERLAPPED ; dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; RECT windowRect = {0, 0, windowWidth, windowHeight}; AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle); HWND hwnd = CreateWindowEx( dwExStyle, className, "TODO: App Name", dwStyle, 0, 0, // x and y coords windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, // width, height NULL, // handle to parent NULL, // handle to menu hInstance, // application instance NULL); // no xtra params if (! hwnd) { MessageBox(0, "Main window could not be created", "Error", 0); return 0; } ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); MSG Msg; while (GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; }
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static int ids[]={IDC_INFO,IDC_NSISICON,IDC_SZIPFRAME,IDC_BROWSE,IDC_ZIPFILE,IDC_ZIPINFO_SUMMARY,IDC_ZIPINFO_FILES,IDC_OFRAME,IDC_INAMEST, IDC_INSTNAME,IDC_INSTPATH,IDC_OEFST,IDC_OUTFILE,IDC_BROWSE2,IDC_COMPRESSOR,IDC_ZLIB,IDC_BZIP2,IDC_LZMA,IDC_SOLID,IDC_INTERFACE,IDC_MODERNUI,IDC_CLASSICUI}; static HICON hIcon; static HFONT hFont; if (uMsg == WM_DESTROY) { if (hIcon) DeleteObject(hIcon); hIcon=0; if (hFont) DeleteObject(hFont); hFont=0; } switch (uMsg) { case WM_INITDIALOG: g_hwnd=hwndDlg; CheckDlgButton(hwndDlg,IDC_LZMA,BST_CHECKED); CheckDlgButton(hwndDlg,IDC_MODERNUI,BST_CHECKED); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_poi); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$TEMP")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$SYSDIR")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$WINDIR")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$DESKTOP")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$DESKTOP\\YourNameHere")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$PROGRAMFILES\\YourNameHere")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$STARTMENU")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)_T("$SMPROGRAMS")); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_winamp); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_winamp_plugins); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_winamp_vis); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_winamp_dsp); SendDlgItemMessage(hwndDlg,IDC_INSTPATH,CB_ADDSTRING,0,(LPARAM)gp_winamp_skins); SetDlgItemText(hwndDlg,IDC_INSTPATH,gp_poi); hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON1)); SetClassLong(hwndDlg,GCL_HICON,(long)hIcon); hFont=CreateFont(15,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,FIXED_PITCH|FF_DONTCARE,_T("Courier New")); SendDlgItemMessage(hwndDlg,IDC_OUTPUTTEXT,WM_SETFONT,(WPARAM)hFont,0); DragAcceptFiles(hwndDlg,TRUE); return 1; case WM_CLOSE: if (!g_hThread) { tempzip_cleanup(hwndDlg,0); EndDialog(hwndDlg,1); } break; case WM_USER+1203: if (g_hThread) { if (!lParam) ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_SHOWNA); CloseHandle(g_hThread); g_hThread=0; } made=1; ShowWindow(GetDlgItem(hwndDlg,IDC_BACK),SW_SHOWNA); EnableWindow(GetDlgItem(hwndDlg,IDOK),1); if (nsifilename[0]) DeleteFile(nsifilename); nsifilename[0]=0; break; case WM_DROPFILES: { TCHAR dropped_file[MAX_PATH]=_T(""); if (DragQueryFile((HDROP)wParam,(UINT)-1,NULL,0)==1) { DragQueryFile((HDROP)wParam,0,dropped_file,MAX_PATH); if (lstrlen(dropped_file)>0) { SetZip(hwndDlg,dropped_file); } } else { MessageBox(hwndDlg,_T("Dropping more than one zip file at a time is not supported"),g_errcaption,MB_OK|MB_ICONSTOP); } DragFinish((HDROP)wParam); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BROWSE: if (!g_extracting) { OPENFILENAME l={sizeof(l),}; TCHAR buf[1024]; l.hwndOwner = hwndDlg; l.lpstrFilter = _T("ZIP Files\0*.zip\0All Files\0*.*\0"); l.lpstrFile = buf; l.nMaxFile = 1023; l.lpstrTitle = _T("Open ZIP File"); l.lpstrDefExt = _T("zip"); l.lpstrInitialDir = NULL; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST; buf[0]=0; if (GetOpenFileName(&l)) { SetZip(hwndDlg,buf); } } break; case IDC_BROWSE2: { OPENFILENAME l={sizeof(l),}; TCHAR buf[1024]; l.hwndOwner = hwndDlg; l.lpstrFilter = _T("Executables\0*.exe\0All Files\0*.*\0"); l.lpstrFile = buf; l.nMaxFile = 1023; l.lpstrTitle = _T("Select Output EXE File"); l.lpstrDefExt = _T("exe"); l.lpstrInitialDir = NULL; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER; GetDlgItemText(hwndDlg,IDC_OUTFILE,buf,sizeof(buf)); if (GetSaveFileName(&l)) { SetDlgItemText(hwndDlg,IDC_OUTFILE,buf); } } break; case IDC_BACK: if (!g_hThread) { made=0; ShowWindow(GetDlgItem(hwndDlg,IDC_BACK),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_HIDE); { for (size_t x = 0; x < COUNTOF(ids); x ++) ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_SHOWNA); SetDlgItemText(hwndDlg,IDOK,_T("&Generate")); EnableWindow(GetDlgItem(hwndDlg,IDOK),1); } } break; case IDC_TEST: if (!g_hThread) { TCHAR buf[1024]; GetDlgItemText(hwndDlg,IDC_OUTFILE,buf,COUNTOF(buf)); ShellExecute(hwndDlg,_T("open"),buf,_T(""),_T(""),SW_SHOW); } break; case IDOK: if (!g_hThread) { if (!made) { if (IsDlgButtonChecked(hwndDlg,IDC_ZLIB)) g_compressor = 1; if (IsDlgButtonChecked(hwndDlg,IDC_BZIP2)) g_compressor = 2; if (IsDlgButtonChecked(hwndDlg,IDC_LZMA)) g_compressor = 3; if (IsDlgButtonChecked(hwndDlg,IDC_SOLID)) g_compressor_solid = 1; else g_compressor_solid = 0; g_mui=!IsDlgButtonChecked(hwndDlg,IDC_CLASSICUI); SetDlgItemText(g_hwnd, IDC_OUTPUTTEXT, _T("")); for (size_t x = 0; x < COUNTOF(ids); x ++) ShowWindow(GetDlgItem(hwndDlg,ids[x]),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_SHOWNA); SetDlgItemText(hwndDlg,IDOK,_T("&Close")); EnableWindow(GetDlgItem(hwndDlg,IDOK),0); makeEXE(hwndDlg); } else { tempzip_cleanup(hwndDlg,0); EndDialog(hwndDlg,0); } } break; } break; } return 0; }
gboolean gst_gl_window_win32_create_window (GstGLWindowWin32 * window_win32, GError ** error) { // GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window); WNDCLASSEX wc; ATOM atom = 0; HINSTANCE hinstance = GetModuleHandle (NULL); static gint x = 0; static gint y = 0; GST_LOG ("Attempting to create a win32 window"); x += 20; y += 20; atom = GetClassInfoEx (hinstance, "GSTGL", &wc); if (atom == 0) { ZeroMemory (&wc, sizeof (WNDCLASSEX)); wc.cbSize = sizeof (WNDCLASSEX); wc.lpfnWndProc = window_proc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon (NULL, IDI_WINLOGO); wc.hIconSm = NULL; wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "GSTGL"; atom = RegisterClassEx (&wc); if (atom == 0) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED, "Failed to register window class 0x%x\n", (unsigned int) GetLastError ()); goto failure; } } window_win32->internal_win_id = 0; window_win32->device = 0; window_win32->visible = FALSE; window_win32->internal_win_id = CreateWindowEx (0, "GSTGL", "OpenGL renderer", WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, x, y, 0, 0, (HWND) NULL, (HMENU) NULL, hinstance, window_win32); if (!window_win32->internal_win_id) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED, "failed to create gl window"); goto failure; } GST_DEBUG ("gl window created: %" G_GUINTPTR_FORMAT, (guintptr) window_win32->internal_win_id); //device is set in the window_proc if (!window_win32->device) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED, "failed to create device"); goto failure; } ShowCursor (TRUE); GST_LOG ("Created a win32 window"); set_parent_win_id (window_win32); return TRUE; failure: return FALSE; }
void CFileExistsDlg::CreateControls() { wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_FILEEXISTSDLG")); m_pAction1 = wxDynamicCast(FindWindow(XRCID("ID_ACTION1")), wxRadioButton); m_pAction2 = wxDynamicCast(FindWindow(XRCID("ID_ACTION2")), wxRadioButton); m_pAction3 = wxDynamicCast(FindWindow(XRCID("ID_ACTION3")), wxRadioButton); m_pAction4 = wxDynamicCast(FindWindow(XRCID("ID_ACTION4")), wxRadioButton); m_pAction5 = wxDynamicCast(FindWindow(XRCID("ID_ACTION5")), wxRadioButton); m_pAction6 = wxDynamicCast(FindWindow(XRCID("ID_ACTION6")), wxRadioButton); m_pAction7 = wxDynamicCast(FindWindow(XRCID("ID_ACTION7")), wxRadioButton); wxString localFile = m_pNotification->localFile; wxString remoteFile = m_pNotification->remotePath.FormatFilename(m_pNotification->remoteFile); localFile = GetPathEllipsis(localFile, FindWindow(XRCID("ID_FILE1_NAME"))); remoteFile = GetPathEllipsis(remoteFile, FindWindow(XRCID("ID_FILE2_NAME"))); localFile.Replace(_T("&"), _T("&&")); remoteFile.Replace(_T("&"), _T("&&")); const bool thousands_separator = COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0; wxString localSize; if (m_pNotification->localSize != -1) localSize = FormatSize(m_pNotification->localSize, false, 0, thousands_separator, 0) + _T(" ") + _("bytes"); else localSize = _("Size unknown"); wxString remoteSize; if (m_pNotification->remoteSize != -1) remoteSize = FormatSize(m_pNotification->remoteSize, false, 0, thousands_separator, 0) + _T(" ") + _("bytes"); else remoteSize = _("Size unknown"); if (m_pNotification->download) { wxStaticText *pStatText; pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_NAME"))); if (pStatText) pStatText->SetLabel(localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_SIZE"))); if (pStatText) pStatText->SetLabel(localSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_TIME"))); if (pStatText) { if (m_pNotification->localTime.IsValid()) pStatText->SetLabel(m_pNotification->localTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE1_ICON"), m_pNotification->localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_NAME"))); if (pStatText) pStatText->SetLabel(remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_SIZE"))); if (pStatText) pStatText->SetLabel(remoteSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_TIME"))); if (pStatText) { if (m_pNotification->remoteTime.IsValid()) pStatText->SetLabel(m_pNotification->remoteTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE2_ICON"), m_pNotification->remoteFile); wxCheckBox *pCheckBox = reinterpret_cast<wxCheckBox *>(FindWindow(XRCID("ID_UPDOWNONLY"))); if (pCheckBox) pCheckBox->SetLabel(_("A&pply only to downloads")); } else { wxWindow *pStatText; pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_NAME"))); if (pStatText) pStatText->SetLabel(remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_SIZE"))); if (pStatText) pStatText->SetLabel(remoteSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_TIME"))); if (pStatText) { if (m_pNotification->remoteTime.IsValid()) pStatText->SetLabel(m_pNotification->remoteTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE1_ICON"), m_pNotification->remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_NAME"))); if (pStatText) pStatText->SetLabel(localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_SIZE"))); if (pStatText) pStatText->SetLabel(localSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_TIME"))); if (pStatText) { if (m_pNotification->localTime.IsValid()) pStatText->SetLabel(m_pNotification->localTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE2_ICON"), m_pNotification->localFile); wxCheckBox *pCheckBox = reinterpret_cast<wxCheckBox *>(FindWindow(XRCID("ID_UPDOWNONLY"))); if (pCheckBox) pCheckBox->SetLabel(_("A&pply only to uploads")); } }
static void test_Render(void) { IPicture *pic; HRESULT hres; short type; PICTDESC desc; OLE_XSIZE_HIMETRIC pWidth; OLE_YSIZE_HIMETRIC pHeight; COLORREF result, expected; HDC hdc = GetDC(0); /* test IPicture::Render return code on uninitialized picture */ OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (VOID**)&pic); hres = IPicture_get_Type(pic, &type); ok(hres == S_OK, "IPicture_get_Type does not return S_OK, but 0x%08x\n", hres); ok(type == PICTYPE_UNINITIALIZED, "Expected type = PICTYPE_UNINITIALIZED, got = %d\n", type); /* zero dimensions */ hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); /* nonzero dimensions, PICTYPE_UNINITIALIZED */ hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 10, NULL); ole_expect(hres, S_OK); IPicture_Release(pic); desc.cbSizeofstruct = sizeof(PICTDESC); desc.picType = PICTYPE_ICON; desc.u.icon.hicon = LoadIcon(NULL, IDI_APPLICATION); if(!desc.u.icon.hicon){ win_skip("LoadIcon failed. Skipping...\n"); ReleaseDC(NULL, hdc); return; } OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (VOID**)&pic); /* zero dimensions, PICTYPE_ICON */ hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 0, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 10, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 10, 0, 0, 0, 0, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 0, 10, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 10, 0, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); hres = IPicture_Render(pic, hdc, 0, 0, 0, 0, 0, 0, 10, 10, NULL); ole_expect(hres, CTL_E_INVALIDPROPERTYVALUE); /* Check if target size and position is respected */ IPicture_get_Width(pic, &pWidth); IPicture_get_Height(pic, &pHeight); SetPixelV(hdc, 0, 0, 0x00F0F0F0); SetPixelV(hdc, 5, 5, 0x00F0F0F0); SetPixelV(hdc, 10, 10, 0x00F0F0F0); expected = GetPixel(hdc, 0, 0); hres = IPicture_Render(pic, hdc, 1, 1, 9, 9, 0, 0, pWidth, -pHeight, NULL); ole_expect(hres, S_OK); if(hres != S_OK) { IPicture_Release(pic); ReleaseDC(NULL, hdc); return; } /* Evaluate the rendered Icon */ result = GetPixel(hdc, 0, 0); ok(result == expected, "Color at 0,0 should be unchanged 0x%06X, but was 0x%06X\n", expected, result); result = GetPixel(hdc, 5, 5); ok(result != expected || broken(result == expected), /* WinNT 4.0 and older may claim they drew */ /* the icon, even if they didn't. */ "Color at 5,5 should have changed, but still was 0x%06X\n", expected); result = GetPixel(hdc, 10, 10); ok(result == expected, "Color at 10,10 should be unchanged 0x%06X, but was 0x%06X\n", expected, result); IPicture_Release(pic); ReleaseDC(NULL, hdc); }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { // this is the winmain function WNDCLASS winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message //HDC hdc; // generic dc //PAINTSTRUCT ps; // generic paintstruct // first fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window, note the test to see if WINDOWED_APP is // true to select the appropriate window flags if (!(hwnd = CreateWindow(WINDOW_CLASS_NAME, // class WINDOW_TITLE, // title (WINDOWED_APP ? (WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION) : (WS_POPUP | WS_VISIBLE)), 0,0, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hinstance,// instance NULL))) // creation parms return(0); // save the window handle and instance in a global main_window_handle = hwnd; main_instance = hinstance; // resize the window so that client is really width x height if (WINDOWED_APP) { // now resize the window, so the client area is the actual size requested // since there may be borders and controls if this is going to be a windowed app // if the app is not windowed then it won't matter RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1}; // make the call to adjust window_rect AdjustWindowRectEx(&window_rect, GetWindowStyle(main_window_handle), GetMenu(main_window_handle) != NULL, GetWindowExStyle(main_window_handle)); // save the global client offsets, they are needed in DDraw_Flip() window_client_x0 = -window_rect.left; window_client_y0 = -window_rect.top; // now resize the window with a call to MoveWindow() MoveWindow(main_window_handle, 0, // x position 0, // y position window_rect.right - window_rect.left, // width window_rect.bottom - window_rect.top, // height FALSE); // show the window, so there's no garbage on first render ShowWindow(main_window_handle, SW_SHOW); } // end if windowed // perform all game console specific initialization Game_Init(); // disable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, NULL, 0); // enter main event loop while(1) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // shutdown game and release all resources Game_Shutdown(); // enable CTRL-ALT_DEL, ALT_TAB, comment this line out // if it causes your system to crash SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, NULL, 0); // return to Windows like this return(msg.wParam); } // end WinMain
INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: { char buffer[200]; int value = 0; CenterWindow(hDlg); hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); hBrush = CreateSolidBrush(RGB(240, 240, 240)); DisableVisualStylesInterface(hDlg); Button_SetCheck(GetDlgItem(hDlg, IDC_JOY_GUI), GetJoyGUI()); Button_SetCheck(GetDlgItem(hDlg, IDC_DISABLE_TRAY_ICON), GetMinimizeTrayIcon()); Button_SetCheck(GetDlgItem(hDlg, IDC_DISPLAY_NO_ROMS), GetDisplayNoRomsGames()); Button_SetCheck(GetDlgItem(hDlg, IDC_EXIT_DIALOG), GetExitDialog()); Button_SetCheck(GetDlgItem(hDlg, IDC_USE_BROKEN_ICON), GetUseBrokenIcon()); Button_SetCheck(GetDlgItem(hDlg, IDC_STRETCH_SCREENSHOT_LARGER), GetStretchScreenShotLarger()); Button_SetCheck(GetDlgItem(hDlg, IDC_FILTER_INHERIT), GetFilterInherit()); Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT), GetEnableFastAudit()); Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), GetEnableSevenZip()); Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_DATAFILES), GetEnableDatafiles()); Button_SetCheck(GetDlgItem(hDlg, IDC_SKIP_BIOS), GetSkipBiosMenu()); // Get the current value of the control SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETRANGE, true, MAKELPARAM(0, 60)); /* [0, 60] */ SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETTICFREQ, 5, 0); value = GetCycleScreenshot(); SendMessage(GetDlgItem(hDlg, IDC_CYCLETIMESEC), TBM_SETPOS, true, value); snprintf(buffer, WINUI_ARRAY_LENGTH(buffer), "%d", value); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_CYCLETIMESECTXT), buffer); for (int i = 0; i < NUMHISTORYTAB; i++) { (void)ComboBox_InsertString(GetDlgItem(hDlg, IDC_HISTORY_TAB), i, g_ComboBoxHistoryTab[i].m_pText); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), i, g_ComboBoxHistoryTab[i].m_pData); } if (GetHistoryTab() < MAX_TAB_TYPES) (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab()); else (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab() - TAB_SUBTRACT); SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETRANGE, true, MAKELPARAM(0, 50)); /* [0, 50] */ SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETTICFREQ, 5, 0); value = GetScreenshotBorderSize(); SendMessage(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZE), TBM_SETPOS, true, value); snprintf(buffer, WINUI_ARRAY_LENGTH(buffer), "%d", value); win_set_window_text_utf8(GetDlgItem(hDlg, IDC_SCREENSHOT_BORDERSIZETXT), buffer); EnableWindow(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), GetEnableFastAudit() ? true : false); break; } case WM_CTLCOLORDLG: return (LRESULT) hBrush; case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: hDC = (HDC)wParam; SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); return (LRESULT) hBrush; case WM_HSCROLL: HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OnHScroll); break; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_SCREENSHOT_BORDERCOLOR: { CHOOSECOLOR cc; COLORREF choice_colors[16]; for (int i = 0; i < 16; i++) choice_colors[i] = GetCustomColor(i); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hDlg; cc.lpfnHook = &CCHookProc; cc.rgbResult = GetScreenshotBorderColor(); cc.lpCustColors = choice_colors; cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK; if (!ChooseColor(&cc)) return true; for (int i = 0; i < 16; i++) SetCustomColor(i,choice_colors[i]); SetScreenshotBorderColor(cc.rgbResult); UpdateScreenShot(); return true; } case IDC_ENABLE_FASTAUDIT: { bool enabled = Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT)); EnableWindow(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP), enabled ? true : false); return true; } case IDOK: { bool bRedrawList = false; bool checked = false; int value = 0; SetJoyGUI(Button_GetCheck(GetDlgItem(hDlg, IDC_JOY_GUI))); SetMinimizeTrayIcon(Button_GetCheck(GetDlgItem(hDlg, IDC_DISABLE_TRAY_ICON))); SetExitDialog(Button_GetCheck(GetDlgItem(hDlg, IDC_EXIT_DIALOG))); SetEnableFastAudit(Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_FASTAUDIT))); SetEnableSevenZip(Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_SEVENZIP))); SetEnableDatafiles(Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLE_DATAFILES))); SetSkipBiosMenu(Button_GetCheck(GetDlgItem(hDlg, IDC_SKIP_BIOS))); if (Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_PLAYCOUNT))) { for (int i = 0; i < driver_list::total(); i++) ResetPlayCount(i); bRedrawList = true; } if (Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_PLAYTIME))) { for (int i = 0; i < driver_list::total(); i++) ResetPlayTime(i); bRedrawList = true; } value = SendDlgItemMessage(hDlg, IDC_CYCLETIMESEC, TBM_GETPOS, 0, 0); if (GetCycleScreenshot() != value) SetCycleScreenshot(value); value = SendDlgItemMessage(hDlg, IDC_SCREENSHOT_BORDERSIZE, TBM_GETPOS, 0, 0); if (GetScreenshotBorderSize() != value) { SetScreenshotBorderSize(value); UpdateScreenShot(); } checked = Button_GetCheck(GetDlgItem(hDlg, IDC_STRETCH_SCREENSHOT_LARGER)); if (checked != GetStretchScreenShotLarger()) { SetStretchScreenShotLarger(checked); UpdateScreenShot(); } checked = Button_GetCheck(GetDlgItem(hDlg, IDC_FILTER_INHERIT)); if (checked != GetFilterInherit()) { SetFilterInherit(checked); bRedrawList = true; } checked = Button_GetCheck(GetDlgItem(hDlg, IDC_USE_BROKEN_ICON)); if (checked != GetUseBrokenIcon()) { SetUseBrokenIcon(checked); bRedrawList = true; } checked = Button_GetCheck(GetDlgItem(hDlg, IDC_DISPLAY_NO_ROMS)); if (checked != GetDisplayNoRomsGames()) { SetDisplayNoRomsGames(checked); bRedrawList = true; } int nCurSelection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB)); int nHistoryTab = 0; if (nCurSelection != CB_ERR) nHistoryTab = ComboBox_GetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nCurSelection); DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); if(GetHistoryTab() != nHistoryTab) { SetHistoryTab(nHistoryTab, true); ResizePickerControls(GetMainWindow()); UpdateScreenShot(); } if(bRedrawList) UpdateListView(); SaveInternalUI(); return true; } case IDCANCEL: DestroyIcon(hIcon); DeleteObject(hBrush); EndDialog(hDlg, 0); return true; } break; } return false; }
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; WNDCLASS wc; DWORD dwExStyle; DWORD dwStyle; RECT WindowRect; WindowRect.left=(long)0; WindowRect.right=(long)width; WindowRect.top=(long)0; WindowRect.bottom=(long)height; fullscreen=fullscreenflag; hInstance = GetModuleHandle(NULL); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = (WNDPROC) 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 = "OpenGL"; if (!RegisterClass(&wc)) { MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } if (fullscreen) { DEVMODE dmScreenSettings; memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); dmScreenSettings.dmSize=sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; dmScreenSettings.dmPelsHeight = height; dmScreenSettings.dmBitsPerPel = bits; dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { 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; } else { MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); return FALSE; } } } if (fullscreen) { dwExStyle=WS_EX_APPWINDOW; dwStyle=WS_POPUP; ShowCursor(FALSE); } else { dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle=WS_OVERLAPPEDWINDOW; } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Create The Window if (!(hWnd=CreateWindowEx( dwExStyle, "OpenGL", title, dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, hInstance, NULL))) { KillGLWindow(); MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } static PIXELFORMATDESCRIPTOR pfd= { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; if (!(hDC=GetDC(hWnd))) { KillGLWindow(); MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) { KillGLWindow(); MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) { KillGLWindow(); MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } if (!(hRC=wglCreateContext(hDC))) { KillGLWindow(); MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } if(!wglMakeCurrent(hDC,hRC)) { KillGLWindow(); MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } ShowWindow(hWnd,SW_SHOW); SetForegroundWindow(hWnd); SetFocus(hWnd); ReSizeGLScene(width, height); if (!InitGL()) { KillGLWindow(); MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; } return TRUE; }
INT_PTR CALLBACK ResetDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: CenterWindow(hDlg); hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); hBrush = CreateSolidBrush(RGB(240, 240, 240)); DisableVisualStylesReset(hDlg); return true; case WM_CTLCOLORDLG: return (LRESULT) hBrush; case WM_CTLCOLORSTATIC: case WM_CTLCOLORBTN: hDC = (HDC)wParam; SetBkMode(hDC, TRANSPARENT); SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT)); return (LRESULT) hBrush; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: { bool resetFilters = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_FILTERS)); bool resetGames = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_GAMES)); bool resetDefaults = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_DEFAULT)); bool resetUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_UI)); bool resetInternalUI = Button_GetCheck(GetDlgItem(hDlg, IDC_RESET_MAME_UI)); if (resetFilters || resetGames || resetUI || resetDefaults || resetInternalUI) { char temp[512]; strcpy(temp, MAMEUINAME); strcat(temp, " will now reset the following\n"); strcat(temp, "to the default settings:\n\n"); if (resetDefaults) strcat(temp, "Global games options\n"); if (resetInternalUI) strcat(temp, "Internal MAME interface options\n"); if (resetGames) strcat(temp, "Individual game options\n"); if (resetFilters) strcat(temp, "Custom folder filters\n"); if (resetUI) { strcat(temp, "User interface settings\n\n"); strcat(temp, "Resetting the user interface options\n"); strcat(temp, "requires exiting "); strcat(temp, MAMEUINAME); strcat(temp, ".\n"); } strcat(temp, "\nDo you wish to continue?"); if (win_message_box_utf8(hDlg, temp, "Restore settings", MB_ICONQUESTION | MB_YESNO) == IDYES) { DestroyIcon(hIcon); DeleteObject(hBrush); if (resetFilters) ResetFilters(); if (resetGames) ResetAllGameOptions(); if (resetDefaults) ResetGameDefaults(); if (resetInternalUI) ResetInternalUI(); // This is the only case we need to exit and restart for. if (resetUI) { ResetInterface(); EndDialog(hDlg, 1); return true; } else { EndDialog(hDlg, 0); return true; } } else // Give the user a chance to change what they want to reset. break; } } // Nothing was selected but OK, just fall through case IDCANCEL: DeleteObject(hBrush); DestroyIcon(hIcon); EndDialog(hDlg, 0); return true; } break; } return false; }
HWND CreateOpenGLWindow(char* title, int x, int y, int width, int height, BYTE type, DWORD flags) { int pf; HDC hDC; HWND hWnd; WNDCLASS wc; PIXELFORMATDESCRIPTOR pfd; static HINSTANCE hInstance = 0; /* only register the window class once - use hInstance as a flag. */ if (!hInstance) { hInstance = GetModuleHandle(NULL); wc.style = CS_OWNDC; wc.lpfnWndProc = (WNDPROC)WindowProc; 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 = "OpenGL"; if (!RegisterClass(&wc)) { MessageBox(NULL, "RegisterClass() failed: " "Cannot register window class.", "Error", MB_OK); return NULL; } } hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, x, y, width, height, NULL, NULL, hInstance, NULL); if (hWnd == NULL) { MessageBox(NULL, "CreateWindow() failed: Cannot create a window.", "Error", MB_OK); return NULL; } hDC = GetDC(hWnd); /* there is no guarantee that the contents of the stack that become the pfd are zeroed, therefore _make sure_ to clear these bits. */ memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | flags; pfd.iPixelType = type; pfd.cColorBits = 32; pf = ChoosePixelFormat(hDC, &pfd); if (pf == 0) { MessageBox(NULL, "ChoosePixelFormat() failed: " "Cannot find a suitable pixel format.", "Error", MB_OK); return 0; } if (SetPixelFormat(hDC, pf, &pfd) == FALSE) { MessageBox(NULL, "SetPixelFormat() failed: " "Cannot set format specified.", "Error", MB_OK); return 0; } DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); ReleaseDC(hWnd, hDC); return hWnd; }
bool create_window(void) { WNDCLASSEX wndClass; ZeroMemory (&wndClass, sizeof (wndClass)); wndClass.cbSize = sizeof (wndClass); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInst; wndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); wndClass.hIconSm = NULL; wndClass.hCursor = LoadCursor (NULL, IDC_ARROW); wndClass.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = "blackscreen"; if (!RegisterClassEx(&wndClass)) { // return false; } RECT clientRect; clientRect.left = 0; clientRect.top = 0; clientRect.right = GetSystemMetrics(SM_CXSCREEN); clientRect.bottom = GetSystemMetrics(SM_CYSCREEN); UINT x(GetSystemMetrics(SM_XVIRTUALSCREEN)); UINT y(GetSystemMetrics(SM_YVIRTUALSCREEN)); UINT cx(GetSystemMetrics(SM_CXVIRTUALSCREEN)); UINT cy(GetSystemMetrics(SM_CYVIRTUALSCREEN)); clientRect.left = x; clientRect.top = y; clientRect.right = x + cx; clientRect.bottom = y + cy; AdjustWindowRect (&clientRect, WS_CAPTION, FALSE); hwnd = CreateWindowEx (0, "blackscreen", "blackscreen", WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN|WS_BORDER, CW_USEDEFAULT, CW_USEDEFAULT, cx, cy, NULL, NULL, hInst, NULL); typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD); PSLWA pSetLayeredWindowAttributes=NULL; /* * Code that follows allows the program to run in * environment other than windows 2000 * without crashing only difference being that * there will be no transparency as * the SetLayeredAttributes function is available only in * windows 2000 */ HMODULE hDLL = LoadLibrary ("user32"); if (hDLL) pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes"); /* * Make the windows a layered window */ #ifndef _X64 LONG style = GetWindowLong(hwnd, GWL_STYLE); style = GetWindowLong(hwnd, GWL_STYLE); style &= ~(WS_DLGFRAME | WS_THICKFRAME); SetWindowLong(hwnd, GWL_STYLE, style); #else LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE); style = GetWindowLongPtr(hwnd, GWL_STYLE); style &= ~(WS_DLGFRAME | WS_THICKFRAME); SetWindowLongPtr(hwnd, GWL_STYLE, style); #endif if (pSetLayeredWindowAttributes != NULL) { #ifndef _X64 SetWindowLong (hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) |WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST); #else SetWindowLongPtr (hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) |WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST); #endif ShowWindow (hwnd, SW_SHOWNORMAL); } if (pSetLayeredWindowAttributes != NULL) { /** * Second parameter RGB(255,255,255) sets the colorkey to white * LWA_COLORKEY flag indicates that color key is valid * LWA_ALPHA indicates that ALphablend parameter (factor) * is valid */ pSetLayeredWindowAttributes (hwnd, RGB(255,255,255), 255, LWA_ALPHA); } SetWindowPos(hwnd,HWND_TOPMOST,x,y,cx,cy, SWP_FRAMECHANGED|SWP_NOACTIVATE); //SM_CXVIRTUALSCREEN return true; }
bool GLWindow::create(int width, int height, int bpp, bool fullscreen) { DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style m_isFullscreen = fullscreen; //Store the fullscreen flag m_windowRect.left = (long)0; // Set Left Value To 0 m_windowRect.right = (long)width; // Set Right Value To Requested Width m_windowRect.top = (long)0; // Set Top Value To 0 m_windowRect.bottom = (long)height; // Set Bottom Value To Requested Height // fill out the window class structure m_windowClass.cbSize = sizeof(WNDCLASSEX); m_windowClass.style = CS_HREDRAW | CS_VREDRAW; m_windowClass.lpfnWndProc = GLWindow::StaticWndProc; //We set our static method as the event handler m_windowClass.cbClsExtra = 0; m_windowClass.cbWndExtra = 0; m_windowClass.hInstance = m_hinstance; m_windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); // default icon m_windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); // default arrow m_windowClass.hbrBackground = NULL; // don't need background m_windowClass.lpszMenuName = NULL; // no menu m_windowClass.lpszClassName = "GLClass"; m_windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); // windows logo small icon // register the windows class if (!RegisterClassEx(&m_windowClass)) { return false; } if (m_isFullscreen) //If we are fullscreen, we need to change the display mode { DEVMODE dmScreenSettings; // device mode memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = width; // screen width dmScreenSettings.dmPelsHeight = height; // screen height dmScreenSettings.dmBitsPerPel = bpp; // bits per pixel dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { // setting display mode failed, switch to windowed MessageBox(NULL, "Display mode failed", NULL, MB_OK); m_isFullscreen = false; } } if (m_isFullscreen) // 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(&m_windowRect, dwStyle, false, dwExStyle); // Adjust Window To True Requested Size // class registered, so now create our window m_hwnd = CreateWindowEx(NULL, // extended style "GLClass", // class name "David Schneider - FPS Demo", // app name dwStyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, // x,y coordinate m_windowRect.right - m_windowRect.left, m_windowRect.bottom - m_windowRect.top, // width, height NULL, // handle to parent NULL, // handle to menu m_hinstance, // application instance this); // we pass a pointer to the GLWindow here // check if window creation failed (hwnd would equal NULL) if (!m_hwnd) return 0; m_hdc = GetDC(m_hwnd); ShowWindow(m_hwnd, SW_SHOW); // display the window UpdateWindow(m_hwnd); // update the window m_lastTime = GetTickCount() / 1000.0f; //Initialize the time return true; }
HWND CreateOpenGLWindow(char* title, int x, int y, int width, int height, BYTE type, DWORD flags) { int n, pf; HWND hWnd; WNDCLASS wc; LOGPALETTE* lpPal; PIXELFORMATDESCRIPTOR pfd; static HINSTANCE hInstance = 0; /* only register the window class once - use hInstance as a flag. */ if (!hInstance) { hInstance = GetModuleHandle(NULL); wc.style = CS_OWNDC; wc.lpfnWndProc = (WNDPROC)WindowProc; 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 = "OpenGL"; if (!RegisterClass(&wc)) { MessageBox(NULL, "RegisterClass() failed: " "Cannot register window class.", "Error", MB_OK); return NULL; } } hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, x, y, width, height, NULL, NULL, hInstance, NULL); if (hWnd == NULL) { MessageBox(NULL, "CreateWindow() failed: Cannot create a window.", "Error", MB_OK); return NULL; } hDC = GetDC(hWnd); /* there is no guarantee that the contents of the stack that become the pfd are zeroed, therefore _make sure_ to clear these bits. */ memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | flags; pfd.iPixelType = type; pfd.cColorBits = 32; pf = ChoosePixelFormat(hDC, &pfd); if (pf == 0) { MessageBox(NULL, "ChoosePixelFormat() failed: " "Cannot find a suitable pixel format.", "Error", MB_OK); return 0; } if (SetPixelFormat(hDC, pf, &pfd) == FALSE) { MessageBox(NULL, "SetPixelFormat() failed: " "Cannot set format specified.", "Error", MB_OK); return 0; } DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); if (pfd.dwFlags & PFD_NEED_PALETTE || pfd.iPixelType == PFD_TYPE_COLORINDEX) { n = 1 << pfd.cColorBits; if (n > 256) n = 256; lpPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n); memset(lpPal, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n); lpPal->palVersion = 0x300; lpPal->palNumEntries = n; GetSystemPaletteEntries(hDC, 0, n, &lpPal->palPalEntry[0]); /* if the pixel type is RGBA, then we want to make an RGB ramp, otherwise (color index) set individual colors. */ if (pfd.iPixelType == PFD_TYPE_RGBA) { int redMask = (1 << pfd.cRedBits) - 1; int greenMask = (1 << pfd.cGreenBits) - 1; int blueMask = (1 << pfd.cBlueBits) - 1; int i; /* fill in the entries with an RGB color ramp. */ for (i = 0; i < n; ++i) { lpPal->palPalEntry[i].peRed = (((i >> pfd.cRedShift) & redMask) * 255) / redMask; lpPal->palPalEntry[i].peGreen = (((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask; lpPal->palPalEntry[i].peBlue = (((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask; lpPal->palPalEntry[i].peFlags = 0; } } else {
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { WNDCLASSEX wc={sizeof(WNDCLASSEX), CS_CLASSDC | CS_DBLCLKS, MsgProc, 0L, 0L, GetModuleHandle(NULL), LoadIcon(hInstance, (LPCSTR)IDI_3DFX), LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, "My D3D Application", NULL}; RegisterClassEx(&wc); hWnd=CreateWindow("My D3D Application", "My Effect", WS_OVERLAPPEDWINDOW, WindowX, WindowY, WindowWidth, WindowHeight, GetDesktopWindow(), NULL, wc.hInstance, NULL); //SetWindowLong( hWnd, GWL_STYLE, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX); char pInfo[500]; UINT InfoID = 0; if(SUCCEEDED(InitD3D(hInstance))) { InfoID = InitMyScene(); ShowWindow(hWnd,SW_SHOWDEFAULT); UpdateWindow(hWnd); MSG msg; while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); #ifndef USE_DEBUG //非DEBUG的时候有错误不能直接弹出对话框,要根据函数返回值退出后再提示,另外要用RELEASE版编译后运行才不会在退出显示MESSAGEBOX时出错 if(InfoID != 0) { SendMessage(hWnd, WM_CLOSE, 0, 0); continue; } #endif if(msg.message==WM_CLOSE) break; ControlProc(); //显示出错,可能是重置设备或切换分辨率的问题 InfoID = DisplayMyScene(); #ifndef USE_DEBUG //非DEBUG的时候有错误不能直接弹出对话框,要根据函数返回值退出后再提示,另外要用RELEASE版编译后运行才不会在退出显示MESSAGEBOX时出错 if(InfoID != 0) { SendMessage(hWnd, WM_CLOSE, 0, 0); continue; } #endif } } ReleaseD3D(); UnregisterClass("My D3D Application", wc.hInstance); LoadString(hInstance, InfoID, pInfo, 500); // 如果直接返回E_FAIL,就不要提示了(表示该错误类型内部字串中是没有的),直接退出即可 if(InfoID != 0 && InfoID != E_FAIL) MessageBox(NULL, pInfo, "Fatal Error", MB_OK); return(0); }
//-------------------------------------------------------------------- // Function: Cls_OnInitDialog // // Description: // // Input: hwnd - // hwndFocus - // lParam - // // Modifies: // // Returns: // //-------------------------------------------------------------------- static BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { UINT uRet = 0; HWND hwndChild; int i; //char cBuf[128]; #ifndef WIN32 HFONT hFontDialog; #endif // initialize timer count timerCount = 0; // Load Icons hTimers[0] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER0)); hTimers[1] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER1)); hTimers[2] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER2)); hTimers[3] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER3)); hTimers[4] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER4)); hTimers[5] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER5)); hTimers[6] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER6)); hTimers[7] = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TIMER7)); #ifndef WIN32 hwndChild = GetFirstChild(hwnd); hFontDialog = GetWindowFont(hwndChild); while (hwndChild) { SetWindowFont(hwndChild, hFontDialog, FALSE); hwndChild = GetNextSibling(hwndChild); } #endif //LoadString(hInstance, IDS_CHANGE_MODE_TITLE, cBuf, sizeof(cBuf)); //SetDlgItemText(hwnd, IDC_CHANGING_MODE, cBuf); if (hwndChild = GetDlgItem(hwnd, IDC_PROGRESS_BAR)) { SetWindowWord(hwndChild, GWW_TRAYLEVEL, 1100); } //{ char szBuffer[128]; wsprintf(szBuffer, "HPECLUI: waitdlgx: Setting timer...\r\n"); OutputDebugString(szBuffer); } //---------------------------------------------------------------- // Start the timer a tickin... //---------------------------------------------------------------- uRet = SetTimer(hwnd, TIMER_ID, TIMER_VALUE, NULL); Cls_OnTimer(hwnd, TIMER_ID); //---------------------------------------------------------------- // If SetTimer() failed, kludge it a little and use Sleep() - // saw this on Stuart G's PC - has dual boot... //---------------------------------------------------------------- if (uRet == 0) { for (i=0; i<NUM_TICKS; i++) { //------------------------------------------------------------ // Something's wrong, wait a while, then exit... //------------------------------------------------------------ #ifdef WIN32 Sleep (TIMER_VALUE); #endif Cls_OnTimer(hwnd, TIMER_ID); } EndDialog (hwnd, TIMER_ID); } return TRUE; }
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow) { HWND hwnd; MSG msg; WNDCLASS wndclass; INITCOMMONCONTROLSEX ice; HACCEL hAccelTable; hInstance = hInst; /* Load application title */ LoadString(hInst, IDS_SPI_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0])); /* Load MsgBox() texts here to avoid loading them many times later */ LoadString(hInst, IDS_SPI_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0])); LoadString(hInst, IDS_SPI_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0])); LoadString(hInst, IDS_SPI_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0])); LoadString(hInst, IDS_SPI_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0])); /* Window class for the main application parent window */ wndclass.style = 0; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInst; wndclass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_SPIDER)); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)NULL; wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); ice.dwSize = sizeof(ice); ice.dwICC = ICC_BAR_CLASSES; InitCommonControlsEx(&ice); srand((unsigned)GetTickCount()); /* InitCardLib(); */ /* Construct the path to our help file */ MakePath(szHelpPath, MAX_PATH, _T(".hlp")); hwnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 0, /*The real size will be computed in WndProc through WM_GETMINMAXINFO */ 0, /* The real size will be computed in WndProc through WM_GETMINMAXINFO */ NULL, NULL, hInst, NULL); hwndMain = hwnd; ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIFFICULTY), hwnd, DifficultyDlgProc); while(GetMessage(&msg, NULL,0,0)) { if(!TranslateAccelerator(hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }