예제 #1
0
파일: DlgMain.c 프로젝트: chrisdone/hugs
INT_PTR CALLBACK MainDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
	case WM_INITDIALOG:
	    MainInitDialog(hWnd);
	    break;

	case WM_DROPFILES:
	    MainDropFiles(hWnd, (HDROP) wParam);
	    break;

	case WM_APP:
	    FireCommand(CommandDelayBuffer);
	    break;

	case WM_COMMAND:
	    MainCommand(hWnd, LOWORD(wParam));
	    break;

	case WM_NOTIFY:
	    return MainNotify(hWnd, (LPNMHDR) lParam);
	    break;

	case WM_SIZE:
	    MainSize(hWnd, LOWORD(lParam), HIWORD(lParam));
	    break;

	case WM_MENUSELECT:
	    MainMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam));
	    break;

	case WM_TIMER:
	    RtfWindowTimer();;
	    break;

	case WM_CONTEXTMENU:
	    {
		HWND hParam = (HWND) wParam;
		HWND hRtfChild = GetDlgItem(hWnd, ID_RTF);
		if (hParam == hWnd || hParam == hRtfChild)
		    ShowContextMenu(LOWORD(lParam), HIWORD(lParam));
	    }
	    break;

	case WM_HELP:
	    MainCommand(hWnd, ID_HELPCONTENTS);
	    break;

	case WM_CLOSE:
	    RegistryWriteWindowPos(hWnd);
	    if (Running)
		AbortExecution();
	    PostQuitMessage(0);
	    break;
    }

    return FALSE;
}
/****************************************************************\
 *  Main client window procedure
 *--------------------------------------------------------------
 *
 *  Name:   MainWndProc(hwnd, msg, mp1, mp2)
 *
 *  Purpose: Processes the messages sent to the main client
 *              window.  This routine processes the basic
 *              messages all client windows should process
 *              and passes all others onto WinDefWindowProc.
 *
 *  Usage:  Called for each message placed in the main
 *          window's message queue
 *
 *  Method: a switch statement branches to the routines to be
 *          performed for each message processed.
 *
 *  Returns:  Return values are determined by each message
 *
\****************************************************************/
MRESULT EXPENTRY MainWndProc(HWND   hwnd,    /* handle of window */
                             ULONG  msg,     /* id of message */
                             MPARAM mp1,     /* first message parameter */
                             MPARAM mp2)     /* second message parameter */
{
   QDATA   *pqdataQ;

   switch(msg)
   {
      case WM_CREATE:
         return InitMainWindow(hwnd, mp1, mp2);
         break;

      case WM_PAINT:
         MainPaint(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_SIZE:
         MainSize(hwnd, sTotalMsgs, mp1, mp2);
         break;

      case WM_HSCROLL:
         MainHorizScroll(hwnd, mp2);
         break;

      case WM_VSCROLL:
         MainVertScroll(hwnd, mp2);
         break;

      case WM_CHAR:
         switch (SHORT2FROMMP(mp2))
         {
            case VK_LEFT:
            case VK_RIGHT:
               return MainCharHScroll (hwnd, msg, mp1, mp2) ;
            case VK_UP:
            case VK_DOWN:
            case VK_PAGEUP:
            case VK_PAGEDOWN:
               return MainCharVScroll (hwnd, msg, mp1, mp2) ;
         }
         break ;

      case WM_COMMAND:
         MainCommand(mp1, mp2);
         break;

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)PANEL_HELPKEYS;   /* return id of key help panel */
         break ;

      case WM_NEWQMSG:
         /* copy message into circular array, with index being next free spot in array */
         pqdataQ = (QDATA *)PVOIDFROMMP(mp1);
         sprintf(SvrQMsgs[iIndex],
                 "Process ID: %03lu, Priority: %02hu,  Message: %s",
                 pqdataQ->pidProcess,
                 pqdataQ->usPriority,
                 pqdataQ->pszMsg);

         /* increment index, or reset to 0 as appropriate */
         iIndex = (iIndex < MAX_MESSAGES - 1) ? iIndex + 1 : 0;

         /* increment total message count until buffer is filled */
         sTotalMsgs = min(MAX_MESSAGES, sTotalMsgs + 1);

         MainUpdateMsg(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_MSG:
         MessageBox(hwndMain, (ULONG)SHORT1FROMMP(mp1), MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL, TRUE);
         break;

      case WM_CLOSE:
         DosWriteQueue(hqQ, WM_CLOSE, 0UL, NULL, 15UL);

         /* process the WM_CLOSE */

   /*--------------------------------------------------*\
    *      Any messages not processed are passed on
    *      to WinDefWindowProc.
   \*--------------------------------------------------*/

      default:
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
         break;
   }

   return MRFROMLONG(0L);     /* all window procedures should return 0 as a default */

}   /* MainWndProc() */
예제 #3
0
파일: WndMain.c 프로젝트: arcanelab/WinGHCi
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {

		case WM_NOTIFY:		
			return MainNotify(hWnd, (LPNMHDR) lParam);
			break;

		case WM_CREATE:
			MainCreate(hWnd);
			break;

		case WM_DROPFILES:
			MainDropFiles(hWnd, (HDROP) wParam);
			break;

		case WM_COMMAND: 
			MainCommand(hWnd, LOWORD(wParam));		
			break;

		case WM_SIZE:
			MainSize(hWnd, LOWORD(lParam), HIWORD(lParam));
			break;

		case WM_MENUSELECT:
			MainMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam));
			break;

		case WM_SETFOCUS:
			SetFocus(hWndRtf);
			break;

		case WM_CONTEXTMENU: {
				HWND hParam = (HWND) wParam;
				HWND hRtfChild = GetDlgItem(hWnd, IDC_Rtf);
				if (hParam == hWnd || hParam == hRtfChild)
					ShowContextMenu(LOWORD(lParam), HIWORD(lParam));
			}
			break;

		case WM_HELP:		
			MainCommand(hWnd, ID_HELPCONTENTS);
			break;

		case WM_CLOSE:
			FinalizeWinGHCi();

			if (Running)
				AbortExecution();

			FireAsyncCommand(TEXT(":quit"));

			// should not be necessary
			SetEvent(hKillGHCi);

			PostQuitMessage(0);
			break;
		default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	return 0;
}