LRESULT CALLBACK WndProc (HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { // Check which message was passed in switch (iMsg) { case WM_COMMAND: // Check if we have a command from the user HandleMenu(LOWORD(wParam)); // Pass in the command ID to our menu function break; case WM_MOUSEMOVE: // If the mouse moves g_cursorPos.x = LOWORD(lParam); // Store the current cursor position g_cursorPos.y = HIWORD(lParam); break; // This gets rid of unnecessary erasing of the window (eliminates flickering) case WM_ERASEBKGND: return 1; // This message is sent when the window is destroyed case WM_DESTROY: // Tell the window we need to close PostQuitMessage(0); break; // Process default messages default: return DefWindowProc (hWnd, iMsg, wParam, lParam); } // Return zero if we handle message return 0; }
LRESULT CBaseDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: { WORD idFrom = LOWORD(wParam); // idFrom is the menu item selected if (HandleMenu(idFrom)) return S_OK; break; } case WM_PAINT: { // Paint the status, then let the rest draw itself. DrawStatus( m_hWnd, GetStatusHeight(), (LPCTSTR)m_StatusMessages[STATUSDATA1], m_StatusWidth[STATUSDATA1], (LPCTSTR)m_StatusMessages[STATUSDATA2], m_StatusWidth[STATUSDATA2], (LPCTSTR)m_StatusMessages[STATUSINFOTEXT]); break; } } // end switch return CMyDialog::WindowProc(message, wParam, lParam); } // CBaseDialog::WindowProc
BOOLEAN NDAAction(EventRecord *sysEvent, int code) { int event; static EventRecord localEvent; unsigned int eventCode; BOOLEAN result = FALSE; switch (code) { case runAction: return result; case eventAction: BlockMove((Pointer)sysEvent, (Pointer)&localEvent, 16); localEvent.wmTaskMask = 0x001FFFFF; eventCode = TaskMasterDA(0, &localEvent); switch(eventCode) { case updateEvt: BeginUpdate(gCalcWinPtr); DrawContents(); EndUpdate(gCalcWinPtr); break; case wInControl: HandleControl(&localEvent); break; case keyDownEvt: case autoKeyEvt: HandleKey(&localEvent); break; } break; case cutAction: case copyAction: case pasteAction: case clearAction: result = TRUE; HandleMenu(code); break; } return result; }
LRESULT CALLBACK WndProc (HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { // Check which message was passed in switch (iMsg) { case WM_COMMAND: // Check if we have a command from the user HandleMenu(LOWORD(wParam)); // Pass in the command ID to our menu function break; case WM_KEYDOWN: switch (wParam) { case VK_ESCAPE: // Tell the window we want to QUIT PostQuitMessage(0); break; } break; case WM_LBUTTONDOWN: // If we hit the left mouse button g_bLButtonDown = true; // Set our global boolean to true break; case WM_LBUTTONUP: // If we let off of the left button g_bLButtonDown = false; // Set our global boolean value to false break; case WM_RBUTTONDOWN: // If we click the right button if(g_pCursorTile == NULL) // If we don't have a current cursor tile { // Here we delete the tile at our current mouse position from the map g_pCurrentMap->DeleteTile(g_cursorPos.x/TILE_WIDTH, g_cursorPos.y/TILE_HEIGHT); } else g_pCursorTile = NULL; // Otherwise remove the cursor tile break; // Don't let the window go inactive case WM_NCACTIVATE: return DefWindowProc(hWnd, iMsg, TRUE, lParam); // This gets rid of unecessary erasing of the window (eliminates flickering) case WM_ERASEBKGND: return 1; // This message is sent when the window is destroyed case WM_DESTROY: // Tell the window we need to close PostQuitMessage(0); break; // Process/handle the default messages default: return DefWindowProc (hWnd, iMsg, wParam, lParam); } // Return zero when we handle a message return 0; }
void DoJukebox(void) { int which,lastsong=-1; unsigned start; unsigned songs[]= { #ifndef SPEAR GETTHEM_MUS, SEARCHN_MUS, POW_MUS, SUSPENSE_MUS, WARMARCH_MUS, CORNER_MUS, NAZI_OMI_MUS, PREGNANT_MUS, GOINGAFT_MUS, HEADACHE_MUS, DUNGEON_MUS, ULTIMATE_MUS, INTROCW3_MUS, NAZI_RAP_MUS, TWELFTH_MUS, ZEROHOUR_MUS, ULTIMATE_MUS, PACMAN_MUS #else XFUNKIE_MUS, // 0 XDEATH_MUS, // 2 XTIPTOE_MUS, // 4 XTHEEND_MUS, // 7 XEVIL_MUS, // 17 XJAZNAZI_MUS, // 18 XPUTIT_MUS, // 21 XGETYOU_MUS, // 22 XTOWER2_MUS // 23 #endif }; IN_ClearKeysDown(); if (!AdLibPresent && !SoundBlasterPresent) return; MenuFadeOut(); #ifndef SPEAR #ifndef UPLOAD start = ((LR_GetTicks()/10)%3)*6; #else start = 0; #endif #else start = 0; #endif CA_CacheGrChunk (STARTFONT+1); #ifdef SPEAR CacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); #else CacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); #endif CA_LoadAllSounds (); fontnumber=1; ClearMScreen (); VWB_DrawPic(112,184,C_MOUSELBACKPIC); DrawStripes (10); SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); #ifndef SPEAR DrawWindow (CTL_X-2,CTL_Y-6,280,13*7,BKGDCOLOR); #else DrawWindow (CTL_X-2,CTL_Y-26,280,13*10,BKGDCOLOR); #endif DrawMenu (&MusicItems,&MusicMenu[start]); SETFONTCOLOR (READHCOLOR,BKGDCOLOR); PrintY = 15; WindowX = 0; WindowY = 320; US_CPrint ("Robert's Jukebox"); SETFONTCOLOR (TEXTCOLOR,BKGDCOLOR); VW_UpdateScreen(); MenuFadeIn(); do { which = HandleMenu(&MusicItems,&MusicMenu[start],NULL); if (which >= 0) { if (lastsong >= 0) MusicMenu[start+lastsong].active = 1; StartCPMusic(songs[start + which]); MusicMenu[start+which].active = 2; DrawMenu (&MusicItems,&MusicMenu[start]); VW_UpdateScreen(); lastsong = which; } } while(which >= 0); MenuFadeOut(); IN_ClearKeysDown(); #ifdef SPEAR UnCacheLump (BACKDROP_LUMP_START,BACKDROP_LUMP_END); #else UnCacheLump (CONTROLS_LUMP_START,CONTROLS_LUMP_END); #endif }
// This function is called by the Windows function DispatchMessage() LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT mMsg, WPARAM wParam, LPARAM lParam) { switch (mMsg) { case WM_CREATE: break; case WM_SIZE: break; case WM_COMMAND: //If handle is the window, handle the menu if (hWnd == cWindow.GetHandle()) HandleMenu(hWnd, LOWORD(wParam)); if (LOWORD(wParam) == IDR_START_BUTTON) { //Check if we have a connection to the scale if (scale != NULL && scale->IsConnected()) { //Check if we just finished a meal as well, if we didn't, start one if (!bMealActive) { //If the meal is not active, start it or reset it if (vMealItems.size() == 0) { _beginthread(Meal, 0, (void*)hWnd); } else { vMealItems.clear(); HandleMenu(hWnd, ID_FILE_NEW); } } else { //Otherwise, stop it if (strlen(cSaveName)<=1) GetSaveFile(hWnd); bMealActive = 0; } } } break; case WM_CLOSE: if (strlen(cSaveName) > 1 && !SaveMeal()) { if (CheckAndSave() == -1) break; } else if (!bSaved && vMealItems.size() > 0) { switch(MessageBox(hWnd, "You haven't saved the current meal, would you like to?","Hold Up!", MB_YESNOCANCEL | MB_ICONINFORMATION)) { case IDYES: if (CheckAndSave() == -1) break; case IDNO: if (scale) delete scale; DestroyWindow(hWnd); hWnd = NULL; break; case IDCANCEL: break; default: break; } } else { if (hWnd != NULL) { if (scale) delete scale; DestroyWindow(hWnd); } } break; case WM_DESTROY: PostQuitMessage(0); break; case WM_UPDATE_READING: //Destroy any spare messages if scale is null if (scale == NULL) break; //Retreive the information and print it on the button char tBuf[32]; sprintf(tBuf, "Connected on %s - %.2f %s %s", scale->GetName(), scale->GetWeight(), scale->GetUnit(), (scale->IsStable()?"":"(unstable)")); cEditBox.SetText(tBuf); hScaleThread = (HANDLE)_beginthread(GetScaleReading, 0, (void*) hWnd); break; case WM_SCALE_CONNECTED: ToggleScaleMenu(1); break; case WM_SCALE_DISCONNECTED: ToggleScaleMenu(0); cEditBox.SetText("Disconnected"); break; default: return DefWindowProc (hWnd, mMsg, wParam, lParam); } return 0; }
/*----------------------------------------------------------------------------- Function: PickList Syntax: ret = PickList(Strings, Count, FixedRows, PosX, PosY) Parameters: Strings: (char **) An array of poiners to strings Count: (int ) Number of Strings FixedRows: (int) Height of Picklist This controls the height of the picklist. If this Value is 0 the list will have as many rows as there are entries up to a max of 8. If this is non-zero it will be the Number of Rows for the picklist up to the number of items. PosX: (int) X position for upper left corner. PosY: (int) Y position for upper left corner. Returns: (PICKRESULTS *) pointer to a structure containing the count of selected items, an array of item indeces and an array of pointers to pointers to strings. ----------------------------------------------------------------------------- History Date Who What Tag -------- --------- ----------------------------------------------- ------- 09/03/95 rlc Creation None 09/04/95 rlc Modified to use PICKRESULTS ----------------------------------------------------------------------------*/ PICKRESULTS *PickList(char **Strings, int Count, int FixedRows, int PosX, int PosY) { int i, cnt; MENU DynaMenu; MENUITEM *pItems; char buf[80]; PICKRESULTS *pPR = NULL, *pPRTemp = NULL, *pPRLast = NULL; /* allocate storage for Count items */ pItems = malloc(Count * sizeof(MENUITEM)); /* Adjust for FixedRows */ if (FixedRows == 0) { FixedRows = 8; }else{ FixedRows = min(FixedRows,Count); } /* now initialize the items */ for(i = 0; i < Count; i++) { sprintf(buf," %s", Strings[i]); pItems[i].Text = strdup(buf); pItems[i].Flags = MA_FUN; pItems[i].ActionPtr = MENUVAL(MenuCallback); } /* If we have some menu items run the menu */ if (Count > 0) { /* Build the menu */ DynaMenu.pMnuWin = NULL; DynaMenu.Flags = 0; DynaMenu.CurItem = 0; DynaMenu.TopItem = 0; DynaMenu.ItmDisp = FixedRows; DynaMenu.ItmCount = Count; DynaMenu.Items = pItems; /* Run the menu */ HandleMenu(&DynaMenu, PosX, PosY); /* Build an array of strings of the selected files */ for(i = 0; i < Count; i++) { if (pItems[i].Text[0] == '') { /* allocate a new entry */ pPRTemp = (PICKRESULTS *)malloc(sizeof(PICKRESULTS)); pPRTemp->Next = NULL; /* See if this is the first entry. If so, start the linked * list with this entry. */ if (!pPR) { pPR = pPRTemp; /* otherwise, use the end list poiner to link this new entry * and then set this new entry as the last entry. */ } else { pPRLast->Next = pPRTemp; } /* fill in this entries data */ pPRLast = pPRTemp; pPRLast->String = strdup((pItems[i].Text)+2); pPRLast->Index = i; } } /* Now free the item strings ... */ for(i = 0; i < Count; i++) free(pItems[i].Text); free(pItems); /* and the storage for the items */ /* return the array of strings */ return(pPR); } else { Count = 0; return(NULL); } }