int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { INITCOMMONCONTROLSEX InitCtrls; int argc; char *argv[MAX_CMDLINE_PARAM]; size_t len; TCHAR *p; TCHAR wbuf[BUFSZ]; char buf[BUFSZ]; DWORD major, minor; boolean resuming; /* OSVERSIONINFO osvi; */ UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); sys_early_init(); /* ensure that we don't access violate on a panic() */ windowprocs.win_raw_print = mswin_raw_print; windowprocs.win_raw_print_bold = mswin_raw_print_bold; /* init applicatio structure */ _nethack_app.hApp = hInstance; _nethack_app.hAccelTable = LoadAccelerators(hInstance, (LPCTSTR) IDC_NETHACKW); _nethack_app.hMainWnd = NULL; _nethack_app.hPopupWnd = NULL; _nethack_app.bmpTiles = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TILES)); if (_nethack_app.bmpTiles == NULL) panic("cannot load tiles bitmap"); _nethack_app.bmpPetMark = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PETMARK)); if (_nethack_app.bmpPetMark == NULL) panic("cannot load pet mark bitmap"); #ifdef USE_PILEMARK _nethack_app.bmpPileMark = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PILEMARK)); if (_nethack_app.bmpPileMark == NULL) panic("cannot load pile mark bitmap"); #endif _nethack_app.bmpRip = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_RIP)); if (_nethack_app.bmpRip == NULL) panic("cannot load rip bitmap"); _nethack_app.bmpSplash = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SPLASH)); if (_nethack_app.bmpSplash == NULL) panic("cannot load splash bitmap"); _nethack_app.bmpMapTiles = _nethack_app.bmpTiles; _nethack_app.mapTile_X = TILE_X; _nethack_app.mapTile_Y = TILE_Y; _nethack_app.mapTilesPerLine = TILES_PER_LINE; _nethack_app.bNoHScroll = FALSE; _nethack_app.bNoVScroll = FALSE; _nethack_app.saved_text = strdup(""); _nethack_app.bAutoLayout = TRUE; _nethack_app.bWindowsLocked = TRUE; _nethack_app.bNoSounds = FALSE; #if 0 /* GdiTransparentBlt does not render spash bitmap for whatever reason */ /* use system-provided TransparentBlt for Win2k+ */ ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); if (osvi.dwMajorVersion >= 5) _nethack_app.lpfnTransparentBlt = GdiTransparentBlt; else #endif _nethack_app.lpfnTransparentBlt = _nhapply_image_transparent; // init controls if (FAILED(GetComCtlVersion(&major, &minor))) { char buf[TBUFSZ]; Sprintf(buf, "Cannot load common control library.\n%s\n%s", "For further information, refer to the installation notes at", INSTALL_NOTES); panic(buf); } if (major < MIN_COMCTLMAJOR || (major == MIN_COMCTLMAJOR && minor < MIN_COMCTLMINOR)) { char buf[TBUFSZ]; Sprintf(buf, "Common control library is outdated.\n%s %d.%d\n%s\n%s", "NetHack requires at least version ", MIN_COMCTLMAJOR, MIN_COMCTLMINOR, "For further information, refer to the installation notes at", INSTALL_NOTES); panic(buf); } ZeroMemory(&InitCtrls, sizeof(InitCtrls)); InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&InitCtrls); /* get command line parameters */ p = _get_cmd_arg(GetCommandLine()); p = _get_cmd_arg(NULL); /* skip first paramter - command name */ for (argc = 1; p && argc < MAX_CMDLINE_PARAM; argc++) { len = _tcslen(p); if (len > 0) { argv[argc] = _strdup(NH_W2A(p, buf, BUFSZ)); } else { argv[argc] = ""; } p = _get_cmd_arg(NULL); } GetModuleFileName(NULL, wbuf, BUFSZ); argv[0] = _strdup(NH_W2A(wbuf, buf, BUFSZ)); if (argc == 2) { TCHAR *savefile = strdup(argv[1]); TCHAR *plname; for (p = savefile; *p && *p != '-'; p++) ; if (*p) { /* we found a '-' */ plname = p + 1; for (p = plname; *p && *p != '.'; p++) ; if (*p) { if (strcmp(p + 1, "NetHack-saved-game") == 0) { *p = '\0'; argv[1] = "-u"; argv[2] = _strdup(plname); argc = 3; } } } free(savefile); } resuming = pcmain(argc, argv); moveloop(resuming); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { if (set_applet_wd() < 0) return -1; #ifdef SEAF_LANG_CHINESE char *seafile_locale_dir = g_build_filename (seafile_bin_dir, "i18n", NULL); /* init i18n */ setlocale (LC_ALL, "zh_CN"); bindtextdomain(GETTEXT_PACKAGE, seafile_locale_dir); bind_textdomain_codeset(GETTEXT_PACKAGE, "GBK"); textdomain(GETTEXT_PACKAGE); #endif if (count_process("seafile-applet") > 1) { MessageBox(NULL, _("Seafile is already running"), "Seafile", MB_OK); exit(1); } int argc; char **argv; char cmdbuf[1024]; GError *err = NULL; WSADATA wsadata; WSAStartup(0x0101, &wsadata); UNREFERENCED_PARAMETER(hPrevInstance); snprintf(cmdbuf, sizeof(cmdbuf), "seafile-applet.exe %s", lpCmdLine); char *xxx = _("Seafile Initialization"); char tmp[128]; snprintf(tmp, sizeof(tmp), "%s", xxx); if (!g_shell_parse_argv (cmdbuf, &argc, &argv, &err)) { if (err) applet_warning ("parse arguments failed %s\n", err->message); applet_exit(1); } g_type_init(); applet = g_new0 (SeafileApplet, 1); seafile_applet_init (hInstance); seafile_applet_start (argc, argv); MSG msg; HACCEL hAccelTable; memset(&msg, 0, sizeof(msg)); hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_STARTINTRAY)); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Sleep(test_main()); /* Sleep(test_main()/1000); .text:0040102A mov ecx, eax .text:0040102C mov eax, 10624DD3h .text:00401031 imul ecx .text:00401033 sar edx, 6 .text:00401036 mov eax, edx .text:00401038 shr eax, 1Fh .text:0040103B add edx, eax .text:0040103D push edx ; dwMilliseconds .text:0040103E call ds:Sleep Sleep(test_main()/10000); .text:0040102A 024 mov ecx, eax .text:0040102C 024 mov eax, 68DB8BADh .text:00401031 024 imul ecx .text:00401033 024 sar edx, 0Ch .text:00401036 024 mov eax, edx .text:00401038 024 shr eax, 1Fh .text:0040103B 024 add edx, eax .text:0040103D 024 push edx ; dwMilliseconds .text:0040103E 028 call ds:Sleep */ // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_PETEST, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_PETEST); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) { Common::EnableCrashingOnCrashes(); bool hideLog = true; #ifdef _DEBUG hideLog = false; #endif g_Config.Load(); VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); // The rest is handled in NativeInit(). for (int i = 1; i < __argc; ++i) { if (__argv[i][0] == '\0') continue; if (__argv[i][0] == '-') { switch (__argv[i][1]) { case 'l': hideLog = false; break; case 's': g_Config.bAutoRun = false; g_Config.bSaveSettings = false; break; } } } //Windows, API init stuff INITCOMMONCONTROLSEX comm; comm.dwSize = sizeof(comm); comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES; InitCommonControlsEx(&comm); timeBeginPeriod(1); MainWindow::Init(_hInstance); HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS); g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS); MainWindow::Show(_hInstance, iCmdShow); host = new WindowsHost(MainWindow::GetHWND(), MainWindow::GetDisplayHWND()); HWND hwndMain = MainWindow::GetHWND(); HMENU menu = GetMenu(hwndMain); //initialize custom controls CtrlDisAsmView::init(); CtrlMemView::init(); CtrlRegisterList::init(); DialogManager::AddDlg(memoryWindow[0] = new CMemoryDlg(_hInstance, hwndMain, currentDebugMIPS)); DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS)); MainWindow::Update(); MainWindow::UpdateMenus(); LogManager::Init(); LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); // Emu thread is always running! EmuThread_Start(); if (g_Config.bBrowse) MainWindow::BrowseAndBoot(""); if (!hideLog) SetForegroundWindow(hwndMain); //so.. we're at the message pump of the GUI thread MSG msg; while (GetMessage(&msg, NULL, 0, 0)) //while no quit { //DSound_UpdateSound(); //hack to make it possible to get to main window from floating windows with Esc if (msg.hwnd != hwndMain && msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE) BringWindowToTop(hwndMain); //Translate accelerators and dialog messages... if (!TranslateAccelerator(hwndMain, hAccelTable, &msg)) { if (!DialogManager::IsDialogMessage(&msg)) { //and finally translate and dispatch TranslateMessage(&msg); DispatchMessage(&msg); } } } VFSShutdown(); LogManager::Shutdown(); DialogManager::DestroyAll(); timeEndPeriod(1); g_Config.Save(); delete host; return 0; }
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wcFrame = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW/*style*/, FrameWndProc, 0/*cbClsExtra*/, 0/*cbWndExtra*/, hInstance, LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)), LoadCursor(0, IDC_ARROW), 0/*hbrBackground*/, 0/*lpszMenuName*/, szFrameClass, (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_MDI_APP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) }; ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class #if 0 WNDCLASS wcChild = { CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW, ChildWndProc, 0/*cbClsExtra*/, 0/*cbWndExtra*/, hInstance, 0/*hIcon*/, LoadCursor(0, IDC_ARROW), 0/*hbrBackground*/, 0/*lpszMenuName*/, szChildClass }; ATOM hChildWndClass = RegisterClass(&wcChild); // register child windows class #else // WNDCLASSEX wcChild = { // sizeof(WNDCLASSEX), // CS_HREDRAW | CS_VREDRAW/*style*/, // ChildWndProc, // 0/*cbClsExtra*/, // sizeof(HANDLE)/*cbWndExtra*/, // hInstance, // LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)), // LoadCursor(0, IDC_ARROW), // 0/*hbrBackground*/, // 0/*lpszMenuName*/, // szChildClass, // (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDC_MDI_APP), IMAGE_ICON, // GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) // }; // ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class #endif HMENU hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP)); HMENU hMenuOptions = GetSubMenu(hMenu, ID_OPTIONS_MENU); // HMENU hChildMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP_CHILD)); INITCOMMONCONTROLSEX icc = { sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES }; HDC hdc = GetDC(0); hMenuFrame = hMenu; // hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MDI_APP)); hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif")); ReleaseDC(0, hdc); hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, // hFrameWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL/*hWndParent*/, hMenuFrame, hInstance, NULL/*lpParam*/); if (!hFrameWnd) { return FALSE; } if (InitCommonControlsEx(&icc)) { int nParts[3]; TBBUTTON toolbarBtns[] = { {0, 0, 0, TBSTYLE_SEP}, {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON}, }; hToolBar = CreateToolbarEx(hFrameWnd, WS_CHILD|WS_VISIBLE, IDC_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns, sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON)); CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED); // Create the status bar hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, "", hFrameWnd, IDC_STATUSBAR); if (!hStatusBar) return FALSE; CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); // Create the status bar panes nParts[0] = 100; nParts[1] = 210; nParts[2] = 400; SendMessage(hStatusBar, SB_SETPARTS, 3, (long)nParts); } else { CheckMenuItem(hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_GRAYED); CheckMenuItem(hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_GRAYED); } ShowWindow(hFrameWnd, nCmdShow); UpdateWindow(hFrameWnd); UpdateStatusBar(); return TRUE; }
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT r; RECT r2; int dx1, dy1, dx2, dy2; static int watchIndex=0; Update_RAM_Watch(); switch(uMsg) { case WM_MOVE: { RECT wrect; GetWindowRect(hDlg,&wrect); ramw_x = wrect.left; ramw_y = wrect.top; break; }; case WM_INITDIALOG: { GetWindowRect(MainWindow->getHWnd(), &r); //Ramwatch window dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); // Gens window dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; // push it away from the main window if we can const int width = (r.right-r.left); const int height = (r.bottom - r.top); const int width2 = (r2.right-r2.left); if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) { r.right += width; r.left += width; } else if((int)r.left - (int)width2 > 0) { r.right -= width2; r.left -= width2; } //----------------------------------------------------------------------------------- //If user has Save Window Pos selected, override default positioning if (RWSaveWindowPos) { //If ramwindow is for some reason completely off screen, use default instead if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.left = ramw_x; //This also ignores cases of windows -32000 error codes //If ramwindow is for some reason completely off screen, use default instead if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN)) ) r.top = ramw_y; //This also ignores cases of windows -32000 error codes } //------------------------------------------------------------------------------------- SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); ramwatchmenu=GetMenu(hDlg); rwrecentmenu=CreateMenu(); UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); const char* names[3] = {"Address","Value","Notes"}; int widths[3] = {62,64,64+51+53}; init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths); /* if (!ResultCount) //TODO what do these do reset_address_info(); else signal_new_frame();*/ ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); // if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); // if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE); Update_RAM_Watch(); DragAcceptFiles(hDlg, TRUE); RefreshWatchListSelectedCountControlStatus(hDlg); return true; break; } case WM_INITMENU: CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; case WM_MENUSELECT: case WM_ENTERSIZEMOVE: break; case WM_NOTIFY: { switch(wParam) { case ID_WATCHES_UPDOWN: { switch(((LPNMUPDOWN)lParam)->hdr.code) { case UDN_DELTAPOS: int delta = ((LPNMUPDOWN)lParam)->iDelta; SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0); break; } } default: { LPNMHDR lP = (LPNMHDR) lParam; switch (lP->code) { case LVN_ITEMCHANGED: // selection changed event { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP; if(pNMListView->uNewState & LVIS_FOCUSED || (pNMListView->uNewState ^ pNMListView->uOldState) & LVIS_SELECTED) { // disable buttons that we don't have the right number of selected items for RefreshWatchListSelectedCountControlStatus(hDlg); } } break; case LVN_GETDISPINFO: { LV_DISPINFO *Item = (LV_DISPINFO *)lParam; Item->item.mask = LVIF_TEXT; Item->item.state = 0; Item->item.iImage = 0; const unsigned int iNum = Item->item.iItem; static char num[11]; switch (Item->item.iSubItem) { case 0: sprintf(num,"%08X",rswatches[iNum].Address); Item->item.pszText = num; return true; case 1: { int i = rswatches[iNum].CurValue; int t = rswatches[iNum].Type; int size = rswatches[iNum].Size; const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X")); if(t=='f') { sprintf(num,"%f",i/4096.0f); } else switch (size) { case 'b': default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; } Item->item.pszText = num; } return true; case 2: Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : ""; return true; default: return false; } } case LVN_ODFINDITEM: { // disable search by keyboard typing, // because it interferes with some of the accelerators // and it isn't very useful here anyway SetWindowLongPtr(hDlg, DWLP_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST))); return 1; } } } } break; } case WM_COMMAND: switch(LOWORD(wParam)) { case RAMMENU_FILE_SAVE: QuickSaveWatches(); break; case RAMMENU_FILE_SAVEAS: return Save_Watches(); case RAMMENU_FILE_OPEN: return Load_Watches(true); case RAMMENU_FILE_APPEND: return Load_Watches(false); case RAMMENU_FILE_NEW: ResetWatches(); return true; case IDC_C_WATCH_REMOVE: { HWND watchListControl = GetDlgItem(hDlg, IDC_WATCHLIST); watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED); while (watchIndex >= 0) { RemoveWatch(watchIndex); ListView_DeleteItem(watchListControl, watchIndex); watchIndex = ListView_GetNextItem(watchListControl, -1, LVNI_ALL | LVNI_SELECTED); } RWfileChanged=true; SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; } case IDC_C_WATCH_EDIT: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); } return true; case IDC_C_WATCH: rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; rswatches[WatchCount].Size = 'b'; rswatches[WatchCount].Type = 's'; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_DUPLICATE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { rswatches[WatchCount].Address = rswatches[watchIndex].Address; rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; rswatches[WatchCount].Size = rswatches[watchIndex].Size; rswatches[WatchCount].Type = rswatches[watchIndex].Type; DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); } return true; case IDC_C_WATCH_SEPARATE: AddressWatcher separator; separator.Address = 0; separator.WrongEndian = false; separator.Size = 'S'; separator.Type = 'S'; InsertWatch(separator, "----------------------------"); SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); return true; case IDC_C_WATCH_UP: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex == 0 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case IDC_C_WATCH_DOWN: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if (watchIndex >= WatchCount - 1 || watchIndex == -1) return true; void *tmp = malloc(sizeof(AddressWatcher)); memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher)); memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher)); free(tmp); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex,0,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1); ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); RWfileChanged=true; return true; } case RAMMENU_FILE_AUTOLOAD: { AutoRWLoad ^= 1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); break; } case RAMMENU_FILE_SAVEWINDOW: { RWSaveWindowPos ^=1; CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); break; } case IDC_C_ADDCHEAT: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); if(watchIndex != -1) { u32 address = rswatches[watchIndex].Address; u8 size = (rswatches[watchIndex].Size=='b') ? 1 : (rswatches[watchIndex].Size=='w' ? 2 : 4); u32 value = rswatches[watchIndex].CurValue; const char* desc = rswatches[watchIndex].comment; CheatsAddDialog(hDlg, address, value, size, desc); } break; } case IDCANCEL: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; default: if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES) OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE); } break; case WM_KEYDOWN: // handle accelerator keys { SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); MSG msg; msg.hwnd = hDlg; msg.message = uMsg; msg.wParam = wParam; msg.lParam = lParam; if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg)) return true; } break; case WM_CLOSE: RamWatchHWnd = NULL; DragAcceptFiles(hDlg, FALSE); EndDialog(hDlg, true); return true; case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; DragQueryFile(hDrop, 0, Str_Tmp, 1024); DragFinish(hDrop); return Load_Watches(true, Str_Tmp); } break; } return false; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); //-------------- M A I N D E L P R O G R A M A D E L R O B O T------------// //---------------------------------------------------------------------------------------------------------- //inicializaion de variables Aria::init(); ArArgumentParser parser(&argc, argv); parser.loadDefaultArguments(); ArSimpleConnector simpleConnector(&parser); ArRobot robot; ArSonarDevice sonar; ArAnalogGyro gyro(&robot); robot.addRangeDevice(&sonar); // presionar tecla escape para salir del programa ArKeyHandler keyHandler; Aria::setKeyHandler(&keyHandler); robot.attachKeyHandler(&keyHandler); printf("You may press escape to exit\n"); // uso de sonares para evitar colisiones con las paredes u // obstaculos grandes, mayores a 8cm de alto ArActionLimiterForwards limiterAction("speed limiter near", 300, 600, 250); ArActionLimiterForwards limiterFarAction("speed limiter far", 300, 1100, 400); ArActionLimiterTableSensor tableLimiterAction; robot.addAction(&tableLimiterAction, 100); robot.addAction(&limiterAction, 95); robot.addAction(&limiterFarAction, 90); // Inicializon la funcion de goto ArActionGoto gotoPoseAction("goto"); robot.addAction(&gotoPoseAction, 50); // Finaliza el goto si es que no hace nada ArActionStop stopAction("stop"); robot.addAction(&stopAction, 40); // Parser del CLI if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed()) { Aria::logOptions(); exit(1); } // Conexion del robot if (!simpleConnector.connectRobot(&robot)) { printf("Could not connect to robot... exiting\n"); Aria::exit(1); } robot.runAsync(true); // enciende motores, apaga sonidos robot.enableMotors(); robot.comInt(ArCommands::SOUNDTOG, 0); const int duration = 100000; //msec ArLog::log(ArLog::Normal, "Completados los puntos en %d segundos", duration/1000); bool first = true; int horiz = 1800; int vert = 380; int goalNum = 0; ArTime start; start.setToNow(); while (Aria::getRunning()) { robot.lock(); // inicia el primer punto if (first || gotoPoseAction.haveAchievedGoal()) { first = false; goalNum++; //cambia de 0 a 1 el contador if (goalNum > 7) goalNum = 1; //comienza la secuencia de puntos if (goalNum == 1) gotoPoseAction.setGoal(ArPose(horiz, vert*0)); else if (goalNum == 2) gotoPoseAction.setGoal(ArPose(0, vert*1)); else if (goalNum == 3) gotoPoseAction.setGoa l(ArPose(horiz, vert*2)+5); else if (goalNum == 4) gotoPoseAction.setGoal(ArPose(0, vert*3)); else if (goalNum == 5) gotoPoseAction.setGoal(ArPose(horiz, vert*4+5)); else if (goalNum == 6) gotoPoseAction.setGoal(ArPose(0, vert*5)); else if (goalNum == 7) gotoPoseAction.setGoal(ArPose(0, vert*0)); ArLog::log(ArLog::Normal, "Siguiente punto en %.0f %.0f", gotoPoseAction.getGoal().getX(), gotoPoseAction.getGoal().getY()); } if(start.mSecSince() >= duration) { ArLog::log(ArLog::Normal, "%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000); gotoPoseAction.cancelGoal(); robot.unlock(); ArUtil::sleep(3000); break; } robot.unlock(); ArUtil::sleep(100); } // Robot desconectado al terminal el sleep Aria::shutdown(); return 0; //---------------------------------------------------------------------------------------------------------- // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_VENTANAROBOT, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_VENTANAROBOT)); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #ifdef _DEBUG // memory leak check ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif char tmpURL[8192]; tmpURL[0]=0; char *chanURL=NULL; //VERSION_EX = 0; iniFileName.set(".\\peercast.ini"); WIN32_FIND_DATA fd; //JP-EX HANDLE hFind; //JP-EX OSVERSIONINFO osInfo; //JP-EX osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX GetVersionEx(&osInfo); if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) winDistinctionNT = true; else winDistinctionNT = false; // off by default now showGUI = false; if (strlen(lpCmdLine) > 0) { char *p; if ((p = strstr(lpCmdLine,"-inifile"))!=NULL) iniFileName.setFromString(p+8); if (strstr(lpCmdLine,"-zen")) showGUI = false; if (strstr(lpCmdLine,"-multi")) allowMulti = true; if (strstr(lpCmdLine,"-kill")) killMe = true; if ((p = strstr(lpCmdLine,"-url"))!=NULL) { p+=4; while (*p) { if (*p=='"') { p++; break; } if (*p != ' ') break; p++; } if (*p) strncpy(tmpURL,p,sizeof(tmpURL)-1); } } // get current path { exePath = iniFileName; char *s = exePath.cstr(); char *end = NULL; while (*s) { if (*s++ == '\\') end = s; } if (end) *end = 0; } if (strnicmp(tmpURL,"peercast://",11)==0) { if (strnicmp(tmpURL+11,"pls/",4)==0) chanURL = tmpURL+11+4; else chanURL = tmpURL+11; showGUI = false; } MSG msg; HACCEL hAccelTable; // Initialize global strings //LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); //LoadString(hInstance, IDC_APP_TITLE, szWindowClass, MAX_LOADSTRING); strcpy(szTitle,"PeerCast"); strcpy(szWindowClass,"PeerCast"); if (!allowMulti) { HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass); if (GetLastError() == ERROR_ALREADY_EXISTS) { HWND oldWin = FindWindow(szWindowClass,NULL); if (oldWin) { if (killMe) { SendMessage(oldWin,WM_DESTROY,0,0); return 0; } if (chanURL) { COPYDATASTRUCT copy; copy.dwData = WM_PLAYCHANNEL; copy.cbData = strlen(chanURL)+1; // plus null term copy.lpData = chanURL; SendMessage(oldWin,WM_COPYDATA,NULL,(LPARAM)©); } else { if (showGUI) SendMessage(oldWin,WM_SHOWGUI,0,0); } } return 0; } } if (killMe) return 0; MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) return FALSE; peercastInst = new MyPeercastInst(); peercastApp = new MyPeercastApp(); peercastInst->init(); LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x"); if (peercastApp->clearTemp()) //JP-EX { DeleteFile("play.pls"); hFind = FindFirstFile("*.asx",&fd); if (hFind != INVALID_HANDLE_VALUE) { do { DeleteFile((char *)&fd.cFileName); } while (FindNextFile(hFind,&fd)); FindClose(hFind); } } if (chanURL) { ChanInfo info; servMgr->procConnectArgs(chanURL,info); chanMgr->findAndPlayChannel(info,false); } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SIMPLE); // setup menu notifes int mask = peercastInst->getNotifyMask(); if (mask & ServMgr::NT_PEERCAST) CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_PEERCAST,MF_CHECKED|MF_BYCOMMAND); if (mask & ServMgr::NT_BROADCASTERS) CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_BROADCASTERS,MF_CHECKED|MF_BYCOMMAND); if (mask & ServMgr::NT_TRACKINFO) CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_TRACKINFO,MF_CHECKED|MF_BYCOMMAND); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon); peercastInst->saveSettings(); peercastInst->quit(); return msg.wParam; }
HACCEL ResourceLoader::loadAccelerator(UINT id) { return LoadAccelerators(m_appInstance, MAKEINTRESOURCE(id)); }
/* * GetFileName - create a window, and get file info */ bool GetFileName( HINSTANCE inst, int shcmd, char *fname ) { BOOL rc; HWND mh,win; HDC dchandle; TEXTMETRIC tm; int x,y,avgx,avgy; int xp,yp,xs,ys; WNDCLASS wc; MSG msg; HANDLE accel; dataPtr = fname; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = StartUpDriver; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = inst; wc.hIcon = LoadIcon( inst, "ApplIcon" ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = GetStockObject( WHITE_BRUSH ); wc.lpszMenuName = ResName( "WSampStartMenu" ); wc.lpszClassName = startClass; rc = RegisterClass( &wc ); if( !rc ) { return( false ); } accel = LoadAccelerators( inst, "ApplAccl" ); if( accel == NULL ) { return( false ); } x = GetSystemMetrics( SM_CXSCREEN ); y = GetSystemMetrics( SM_CYSCREEN ); mh = CreateWindow( startClass, /* class */ "Open Watcom Sampler", /* caption */ WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, /* style */ x/8, /* init. x pos */ y/6, /* init. y pos */ 6*x/8, /* init. x size */ y/2, /* init. y size */ NULL, /* parent window */ NULL, /* menu handle */ inst, /* program handle */ NULL /* create parms */ ); if( !mh ) { return( false ); } ShowWindow( mh, shcmd ); UpdateWindow( mh ); dchandle = GetDC( mh ); GetTextMetrics( dchandle, &tm ); avgx = AvgXChar( tm ); avgy = AvgYChar( tm ); ReleaseDC( mh, dchandle ); mainWindow = mh; xp = 32; yp = y/8-10; ys = avgy+avgy/2; xs = (47+1) * avgx+avgx/2; win = CreateWindow( "STATIC", /* class */ "Sampler Options:", /* caption */ WS_CHILD | ES_LEFT, xp+(14*avgx)-6, /* init. x pos */ yp-3-avgy*3/2, /* init. y pos */ 16*avgx, /* init. x size */ ys, /* init. y size */ mh, /* parent window */ NULL, /* child id */ inst, /* program handle */ NULL /* create parms */ ); ShowWindow( win, SW_SHOWNORMAL ); UpdateWindow( win ); win = CreateWindow( "EDIT", /* class */ NULL, /* caption */ WS_CHILD | ES_LEFT | WS_BORDER | ES_AUTOHSCROLL, xp+7, /* init. x pos */ yp, /* init. y pos */ xs, /* init. x size */ ys, /* init. y size */ mh, /* parent window */ (HMENU)EDIT_ID, /* child id */ inst, /* program handle */ NULL /* create parms */ ); if( win == NULL ) { return( false ); } editChild = win; ShowWindow( win, SW_SHOWNORMAL ); UpdateWindow( win ); oldClassProc = (FARPROC) GetWindowLong( editChild, GWL_WNDPROC ); SetWindowLong( editChild, GWL_WNDPROC, (LONG) SubClassProc ); win = CreateWindow( "BUTTON", /* class */ "&Select File...", /* caption */ WS_CHILD | BS_PUSHBUTTON, xp+(6*avgx)-6, /* init. x pos */ yp+avgy*3, /* init. y pos */ 16*avgx, /* init. x size */ avgy+avgy/2, /* init. y size */ mh, /* parent window */ (HMENU)PUSH_GETFILES_ID,/* child id */ inst, /* program handle */ NULL /* create parms */ ); ShowWindow( win, SW_SHOWNORMAL ); UpdateWindow( win ); win = CreateWindow( "BUTTON", /* class */ "S&tart Sampling", /* caption */ WS_CHILD | BS_PUSHBUTTON, xp+(29*avgx)-6, /* init. x pos */ yp+avgy*3, /* init. y pos */ 16*avgx, /* init. x size */ avgy+avgy/2, /* init. y size */ mh, /* parent window */ (HMENU)PUSH_OK_ID, /* child id */ inst, /* program handle */ NULL /* create parms */ ); ShowWindow( win, SW_SHOWNORMAL ); UpdateWindow( win ); SetFocus( editChild ); while( GetMessage( &msg, NULL, 0, 0 ) ) { if( !TranslateAccelerator( mainWindow, accel, &msg ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } return( canContinue ); } /* GetFileName */
extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE, HINSTANCE, LPTSTR, int nCmdShow) { #ifdef _CRTDBG_MAP_ALLOC _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); #endif // TODO: Place code here. MSG msg = {0}; HACCEL hAccelTable; INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = 0x00004000; //ICC_STANDARD_CLASSES; InitCommonControlsEx(&InitCtrlEx); _bstr_t requestedURL; int argc = 0; WCHAR** argv = CommandLineToArgvW(GetCommandLineW(), &argc); for (int i = 1; i < argc; ++i) { if (!wcsicmp(argv[i], L"--transparent")) s_usesLayeredWebView = true; else if (!wcsicmp(argv[i], L"--desktop")) s_fullDesktop = true; else if (!requestedURL) requestedURL = argv[i]; } // Initialize global strings LoadString(hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInst, IDC_WINLAUNCHER, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInst); if (shouldUseFullDesktop()) computeFullDesktopFrame(); // Init COM OleInitialize(NULL); if (usesLayeredWebView()) { hURLBarWnd = CreateWindow(L"EDIT", L"Type URL Here", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, s_windowPosition.x, s_windowPosition.y + s_windowSize.cy, s_windowSize.cx, URLBAR_HEIGHT, 0, 0, hInst, 0); } else { hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInst, 0); if (!hMainWnd) return FALSE; hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, hMainWnd, 0, hInst, 0); hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0); hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0); ShowWindow(hMainWnd, nCmdShow); UpdateWindow(hMainWnd); } DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC)); DefButtonProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC)); SetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); SetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc)); SetWindowLongPtr(hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc)); SetFocus(hURLBarWnd); RECT clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy }; IWebPreferencesPtr tmpPreferences; if (FAILED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, reinterpret_cast<void**>(&tmpPreferences.GetInterfacePtr())))) goto exit; if (FAILED(tmpPreferences->standardPreferences(&gStandardPreferences.GetInterfacePtr()))) goto exit; if (!setToDefaultPreferences()) goto exit; HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView, reinterpret_cast<void**>(&gWebView.GetInterfacePtr())); if (FAILED(hr)) goto exit; hr = gWebView->QueryInterface(IID_IWebViewPrivate, reinterpret_cast<void**>(&gWebViewPrivate.GetInterfacePtr())); if (FAILED(hr)) goto exit; hr = WebKitCreateInstance(CLSID_WebHistory, 0, __uuidof(gWebHistory), reinterpret_cast<void**>(&gWebHistory.GetInterfacePtr())); if (FAILED(hr)) goto exit; gWebHost = new WinLauncherWebHost(); gWebHost->AddRef(); hr = gWebView->setFrameLoadDelegate(gWebHost); if (FAILED(hr)) goto exit; gPrintDelegate = new PrintWebUIDelegate; gPrintDelegate->AddRef(); hr = gWebView->setUIDelegate(gPrintDelegate); if (FAILED (hr)) goto exit; gAccessibilityDelegate = new AccessibilityDelegate; gAccessibilityDelegate->AddRef(); hr = gWebView->setAccessibilityDelegate(gAccessibilityDelegate); if (FAILED (hr)) goto exit; hr = gWebView->setHostWindow(reinterpret_cast<OLE_HANDLE>(hMainWnd)); if (FAILED(hr)) goto exit; hr = gWebView->initWithFrame(clientRect, 0, 0); if (FAILED(hr)) goto exit; if (!requestedURL) { IWebFramePtr frame; hr = gWebView->mainFrame(&frame.GetInterfacePtr()); if (FAILED(hr)) goto exit; _bstr_t defaultHTML(L"<p style=\"background-color: #00FF00\">Testing</p><img id=\"webkit logo\" src=\"http://webkit.org/images/icon-gold.png\" alt=\"Face\"><div style=\"border: solid blue; background: white;\" contenteditable=\"true\">div with blue border</div><ul><li>foo<li>bar<li>baz</ul>"); frame->loadHTMLString(defaultHTML.GetBSTR(), 0); } hr = gWebViewPrivate->setTransparent(usesLayeredWebView()); if (FAILED(hr)) goto exit; hr = gWebViewPrivate->setUsesLayeredWindow(usesLayeredWebView()); if (FAILED(hr)) goto exit; hr = gWebViewPrivate->viewWindow(reinterpret_cast<OLE_HANDLE*>(&gViewWindow)); if (FAILED(hr) || !gViewWindow) goto exit; if (usesLayeredWebView()) subclassForLayeredWindow(); resizeSubViews(); ShowWindow(gViewWindow, nCmdShow); UpdateWindow(gViewWindow); hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_WINLAUNCHER)); if (requestedURL.length()) loadURL(requestedURL.GetBSTR()); // Main message loop: #if USE(CF) _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopGetMain(), QS_ALLINPUT | QS_ALLPOSTMESSAGE, kCFRunLoopDefaultMode); CFRunLoopRun(); #else while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } #endif exit: gPrintDelegate->Release(); shutDownWebKit(); #ifdef _CRTDBG_MAP_ALLOC _CrtDumpMemoryLeaks(); #endif // Shut down COM. OleUninitialize(); return static_cast<int>(msg.wParam); }
// Program entry point function. int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); // Execute the secondary process, if any. int exit_code = CefExecuteProcess(main_args, app.get()); if (exit_code >= 0) return exit_code; // Retrieve the current working directory. if (_getcwd(szWorkingDir, MAX_PATH) == NULL) szWorkingDir[0] = 0; // Parse command line arguments. The passed in values are ignored on Windows. AppInitCommandLine(0, NULL); CefSettings settings; // Populate the settings based on command line arguments. AppGetSettings(settings); // Initialize CEF. CefInitialize(main_args, settings, app.get()); // Register the scheme handler. scheme_test::InitTest(); HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization if (!InitInstance (hInstance, nCmdShow)) return FALSE; hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT)); // Register the find event message. uFindMsg = RegisterWindowMessage(FINDMSGSTRING); int result = 0; if (!settings.multi_threaded_message_loop) { // Run the CEF message loop. This function will block until the application // recieves a WM_QUIT message. CefRunMessageLoop(); } else { // Create a hidden window for message processing. hMessageWnd = CreateMessageWindow(hInstance); ASSERT(hMessageWnd); MSG msg; // Run the application message loop. while (GetMessage(&msg, NULL, 0, 0)) { // Allow processing of find dialog messages. if (hFindDlg && IsDialogMessage(hFindDlg, &msg)) continue; if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyWindow(hMessageWnd); hMessageWnd = NULL; result = static_cast<int>(msg.wParam); } // Shut down CEF. CefShutdown(); return result; }
// Program entry point function. int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // Retrieve the current working directory. if(_getcwd(szWorkingDir, MAX_PATH) == NULL) szWorkingDir[0] = 0; // Parse command line arguments. The passed in values are ignored on Windows. AppInitCommandLine(0, NULL); CefSettings settings; CefRefPtr<CefApp> app; // Populate the settings based on command line arguments. AppGetSettings(settings, app); // Initialize CEF. CefInitialize(settings, app); // Register the internal client plugin. InitPluginTest(); // Register the internal UI client plugin. InitUIPluginTest(); // Register the internal OSR client plugin. InitOSRPluginTest(); // Register the V8 extension handler. InitExtensionTest(); // Register the scheme handler. InitSchemeTest(); HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT)); // Register the find event message. uFindMsg = RegisterWindowMessage(FINDMSGSTRING); int result = 0; if (!settings.multi_threaded_message_loop) { // Run the CEF message loop. This function will block until the application // recieves a WM_QUIT message. CefRunMessageLoop(); } else { MSG msg; // Run the application message loop. while (GetMessage(&msg, NULL, 0, 0)) { // Allow processing of find dialog messages. if (hFindDlg && IsDialogMessage(hFindDlg, &msg)) continue; if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } result = (int)msg.wParam; } // Shut down CEF. CefShutdown(); return result; }