示例#1
0
文件: trays.c 项目: mingpen/OpenNT
DLL_EXPORT(BOOL) APIENTRY TraysPopupProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	  case WM_INITDIALOG:
	  {
	  	BOOL bReturnValue = (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnTraysInitDialog);
	  	OnActivateDialog(hwnd);
		return bReturnValue;
	  }
		
	  case WM_COMMAND:
		HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnTraysCommand);
		break;

	  case WM_MEASUREITEM:
		HANDLE_WM_MEASUREITEM(hwnd, wParam, lParam, Cls_OnTraysMeasureItem);
		break;

	  case WM_DRAWITEM:
		HANDLE_WM_DRAWITEM(hwnd, wParam, lParam, Cls_OnTraysDrawItem);
		break;
		
	  case WM_HELP:
		return (BOOL)OnF1HelpTrays(wParam, lParam);

	  case WM_CONTEXTMENU:
		return (BOOL)OnContextHelpTrays(wParam, lParam);

	  default:
	  	return FALSE;
	}

	return TRUE;
}
示例#2
0
INT_PTR CALLBACK DirectoriesDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	BOOL bReturn = FALSE;

	switch (Msg)
	{
	case WM_INITDIALOG:
		return (BOOL)HANDLE_WM_INITDIALOG(hDlg, wParam, lParam, Directories_OnInitDialog);

	case WM_COMMAND:
		HANDLE_WM_COMMAND(hDlg, wParam, lParam, Directories_OnCommand);
		bReturn = TRUE;
		break;

	case WM_NOTIFY:
		return (BOOL)HANDLE_WM_NOTIFY(hDlg, wParam, lParam, Directories_OnNotify);

	case WM_CLOSE:
		HANDLE_WM_CLOSE(hDlg, wParam, lParam, Directories_OnClose);
		break;

	case WM_DESTROY:
		HANDLE_WM_DESTROY(hDlg, wParam, lParam, Directories_OnDestroy);
		break;

	default:
		bReturn = FALSE;
	}
	return bReturn;
}
//"Pen and brush settings" dialog procedure
INT_PTR CALLBACK PBDialogProc(HWND hwndDlg,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
	try
	{
		//Message switch
		switch(uMsg)
		{
		//Everything is done with the message cracker macros
		case WM_INITDIALOG:
			return HANDLE_WM_INITDIALOG(hwndDlg,wParam,lParam,PBSettings_OnInitDialog);
		case WM_COMMAND:
			HANDLE_WM_COMMAND(hwndDlg,wParam,lParam,PBSettings_OnCommand);
			return FALSE;
		case WM_NOTIFY:
			return HANDLE_WM_NOTIFY(hwndDlg,wParam,lParam,PBSettings_OnNotify);
		case WM_CLOSE:
			EndDialog(hwndDlg,IDCANCEL);
			return TRUE;
		case WM_DRAWITEM:
			return HANDLE_WM_DRAWITEM(hwndDlg,wParam,lParam,PBSettings_OnDrawItem);
		}
	}
	catch(exception &ex) //Handle exceptions
	{
		ErrMsgBox(hMainWindow,ex,_T(__FUNCSIG__),MB_ICONERROR);
		EndDialog(hwndDlg,IDABORT);
	}
	return FALSE;
}
示例#4
0
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg) {
		case WM_CREATE:	//when this window is made, make its main children
			RECT clientRect;
			GetClientRect(hwnd, &clientRect);
			hwndTree=CreateWindow("TreeWndClass","Tree", WS_CHILD|WS_VISIBLE,0,0,clientRect.right,300,
			hwnd, NULL, NULL, NULL);

			hwndInfobox=CreateWindow("InfoboxWndClass", "Infobox", WS_CHILD|WS_VISIBLE, 0, heightTreeWnd, clientRect.right-123,  clientRect.bottom-heightTreeWnd,
			hwnd, NULL, NULL, NULL);

			break;
		case WM_SIZE:
			GetClientRect(hwnd, &clientRect);
			MoveWindow(hwndTree, 0,0,clientRect.right, heightTreeWnd,1);
			break;
		case WM_COMMAND:
			HANDLE_WM_COMMAND(hwnd,wParam,lParam,MainWndProc_OnCommand);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hwnd,msg,wParam,lParam);
	}
	return 0;
}
示例#5
0
文件: miopanel.c 项目: mingpen/OpenNT
DLL_EXPORT(BOOL) APIENTRY MIOPanelProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	  case WM_INITDIALOG:
		return (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnInitDialog);

	  case WM_DESTROY:
		HANDLE_WM_DESTROY(hwnd, wParam, lParam, Cls_OnDestroy);
		break;

	  case WM_COMMAND:
		HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnCommand);
		break;

	  case WM_HELP:
		return (BOOL)OnF1HelpMIO(wParam, lParam);

	  case WM_CONTEXTMENU:
		return (BOOL)OnContextHelpMIO(wParam, lParam);

	  default:
	  	return FALSE;
	}

	return TRUE;
}
示例#6
0
BOOL CALLBACK LOADDS 
ReadMailDlgProc(HWND hWndMail, UINT wMsg, WPARAM wParam, LPARAM lParam) 
{
  switch (wMsg) 
  {
  case WM_INITDIALOG: 
    {
      DWORD i;
      // Do everything we need to display the message pointed to by
      // mailPtr
      if (!mailPtr)
        break;

      // Start with the basics...
      SetDlgItemText(hWndMail, IDC_EDIT_SUBJECT, mailPtr->lpszSubject);
      SetDlgItemText(hWndMail, IDC_EDIT_DATETIME, mailPtr->lpszDateReceived);
      SetDlgItemText(hWndMail, IDC_EDIT_THREAD, mailPtr->lpszConversationID);
      SetDlgItemText(hWndMail, IDC_EDIT_BODYTEXT, mailPtr->lpszNoteText);

      char    buf[1024];
      wsprintf(buf, "%s (%s)", mailPtr->lpOriginator->lpszName, 
                              mailPtr->lpOriginator->lpszAddress);
      SetDlgItemText(hWndMail, IDC_EDIT_FROM, buf);

      for (i=0; i<mailPtr->nRecipCount; i++)
      {
          wsprintf(buf, "%s (%s)", mailPtr->lpRecips[i].lpszName, 
                                   mailPtr->lpRecips[i].lpszAddress);
          ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS), 
                  ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS)), 
                  buf);
      }

      for (i=0; i<mailPtr->nFileCount; i++)
      {
          ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS), 
                ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS)), 
                mailPtr->lpFiles[i].lpszPathName);
      }
    }
    break;

  case WM_COMMAND:
    HANDLE_WM_COMMAND(hWndMail, wParam, lParam, ProcessReadMailCommand);
    break;

  default:
    return FALSE;
  }
  
  return TRUE;
}
示例#7
0
BOOL EXPORT CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:
		return (BOOL)HANDLE_WM_INITDIALOG(hDlg, wParam, lParam, AboutMixTest_OnInitDialog);
	
	case WM_COMMAND:
		HANDLE_WM_COMMAND(hDlg,	wParam, lParam, AboutMixTest_OnCommand);
		return TRUE;
	}
	return (FALSE);			      /* Didn't process a message    */
}
示例#8
0
// Process Windows messages.				 
LRESULT CALLBACK WinProc(HWND win, UINT msgType, WPARAM wParam, LPARAM lParam) {
	switch (msgType) {
	case WM_CREATE:
		return(HANDLE_WM_CREATE(win, wParam, lParam, onCreate));
	case WM_COMMAND:
		HANDLE_WM_COMMAND(win, wParam, lParam, onCommand);
		return (0);
	case WM_DESTROY:
		HANDLE_WM_DESTROY(win, wParam, lParam, onDestroy);
		return (0);
	case WM_SHOWWINDOW:
		HANDLE_WM_SHOWWINDOW(win, wParam, lParam, onShowWindow);
		return (0);
	}         
	return (DefWindowProc(win, msgType, wParam, lParam));
}
示例#9
0
static UINT CALLBACK SaveHook(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if ( uMsg == WM_COMMAND )
        {
        HANDLE_WM_COMMAND(hWnd, wParam, lParam, SaveOnCommand);
        }
#if defined(WIN32) && defined(WINVER) && WINVER >= 0x0400
    else if ( uMsg == WM_NOTIFY )
        {
        if ( ((LPOFNOTIFY)lParam)->hdr.code == CDN_TYPECHANGE )
            {
            char szFilename[_MAX_PATH + 1];
            char szType[128];
            LPOPENFILENAME lpofn = ((LPOFNOTIFY)lParam)->lpOFN;
            LPCSTR psz;
            UINT i;

            psz = lpofn->lpstrFilter;
            for ( i = 1 /* 1-based index */ ; *psz != '\0' && i < lpofn->nFilterIndex; i++ )
                {
                psz += strlen(psz) + 1;
                psz += strlen(psz) + 1;
                }
            strcpy(szType, psz);
            assert(szType[0] != '\0');
            if ( CommDlg_OpenSave_GetSpec(
                    GetParent(hWnd),
                    szFilename,
                    sizeof(szFilename)) > 1 && szType[0] != '\0' )
                {
                SaveOnTypeSelChange(szType, szFilename);
                CommDlg_OpenSave_SetControlText(GetParent(hWnd), edt1, szFilename);
                }
            else
                {
                /* else it's the null string or an error */
                if ( szType[0] == '\0' )
                    {
                    ErrorMessage(STYLE_ERROR, IDS_SAVEINTERNAL2);
                    }
                }
            }
        }
#endif
    return ( 0 );
}
示例#10
0
BOOL CALLBACK FilterPageProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
    case WM_INITDIALOG:
      return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
    case WM_COMMAND:
      HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
      break;
    case WM_NOTIFY:
      HANDLE_WM_NOTIFY(hWnd, wParam, lParam, onNotify);
      break;

    default:
      return FALSE;
  }
  return TRUE;
}
示例#11
0
BOOL CALLBACK NP_LOADDS ManualDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
    case WM_INITDIALOG:
      return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
    case WM_COMMAND:
      HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
      break;
    case WM_DESTROY:
      HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
      break;

    default:
      return FALSE;
  }
  return TRUE;
}
示例#12
0
文件: popup.c 项目: mingpen/OpenNT
DLL_EXPORT(BOOL) APIENTRY PopupDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg)
	{
	  case WM_INITDIALOG:
	  	return HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnInitDialog);

	  case WM_COMMAND:
	  	HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnCommand);
		break;

	  case WM_SYSCOMMAND:
	  	HANDLE_WM_SYSCOMMAND(hwnd, wParam, lParam, Cls_OnSysCommand);
		break;
	}

	return FALSE;
}
示例#13
0
BOOL CALLBACK LOADDS 
MailDlgProc(HWND hWndMain, UINT wMsg, WPARAM wParam, LPARAM lParam) 
{
  switch (wMsg) 
  {
  case WM_INITDIALOG: 
    break;

  case WM_COMMAND:
    HANDLE_WM_COMMAND(hWndMain, wParam, lParam, ProcessMailCommand);
    break;

  default:
    return FALSE;
  }
  
  return TRUE;
}
示例#14
0
/*@@2->@@*/
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg) {

        int x, y;
        char message[50];
        char b[33];

    	case WM_SIZE:
    		SendMessage(hWndStatusbar,msg,wParam,lParam);
    		InitializeStatusBar(hWndStatusbar,1);
    		break;
    	case WM_MENUSELECT:
    		return MsgMenuSelect(hwnd,msg,wParam,lParam);
    	case WM_COMMAND:
    		HANDLE_WM_COMMAND(hwnd,wParam,lParam,MainWndProc_OnCommand);
    		break;
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		break;
        case WM_LBUTTONDOWN:

             x = GET_X_LPARAM(lParam);
             y = GET_Y_LPARAM(lParam);
             itoa(x,b,10);
             strcpy(message,b);
             itoa(y,b,10);
             strcat(message, " ");
             strcat(message, b);
            UpdateStatusBar( message , 0, 0);
            break;

        case WM_LBUTTONUP:
            UpdateStatusBar( "" , 0, 0);
            break;
        
    	default:
    		return DefWindowProc(hwnd,msg,wParam,lParam);
	}

	return 0;
}
INT_PTR CALLBACK OptionsPageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_INITDIALOG:
            return HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Options_OnInitDialog);

        case WM_COMMAND:
            HANDLE_WM_COMMAND(hwnd, wParam, lParam, Options_OnCommand);
            return TRUE;

        case WM_DESTROY:
            HANDLE_WM_DESTROY(hwnd, wParam, lParam, Options_OnDestroy);
            return TRUE;

        case WM_NOTIFY:
            HANDLE_WM_NOTIFY(hwnd, wParam, lParam, Options_OnNotify);
            return TRUE;
    }

    return FALSE;
}
示例#16
0
static BOOL CALLBACK DirPickDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{
  switch(msg) {
    case WM_INITDIALOG:
      onInitDialog(hWnd, (LPSTR)lParam);
      break;
    case WM_COMMAND:
      HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
      break;
    case WM_MEASUREITEM: 
    {
      static int cyItem = -1;      //Height of a listbox item
      LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
      if(cyItem == -1) 
      {
        HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0L);
        if(hFont == NULL)
          hFont = GetStockFont(SYSTEM_FONT);
        HDC hDC = GetDC(hWnd);
        HFONT hFontOld = SelectFont(hDC, hFont);
        TEXTMETRIC tm;
        GetTextMetrics(hDC, &tm);
        cyItem = max(ITEM_BITMAPHEIGHT, tm.tmHeight);
        SelectFont(hDC, hFontOld);
        ReleaseDC(hWnd, hDC);
      }

      lpmis->itemHeight = cyItem;
    }
      break;
    case WM_DRAWITEM:
      onDrawItem((LPDRAWITEMSTRUCT)lParam, ((UINT)wParam == ID_COMBO_DIR));
      return TRUE; // to prevent default action in listbox (drawing focus)
    default:
      return FALSE;
  }
  return TRUE;
}
示例#17
0
extern BOOL CALLBACK ViewProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
/*All the message-crackers other than HANDLE_WM_INITDIALOG return by
default a void, which comes through as FALSE, but we want to return
a TRUE for messages which really are handled, so we do a (BOOL) ! cast
on those.  We make HANDLE_WM_INITDIALOG  return a 0 for success, so cast
it the same way.*/
	switch (message)
	{
		case WM_INITDIALOG:
			return (BOOL) !HANDLE_WM_INITDIALOG(hDlg, wParam, lParam, MyWnd_INITDIALOG);
		case WM_COMMAND:
			return (BOOL) !HANDLE_WM_COMMAND(hDlg, wParam, lParam, MyWnd_COMMAND);
		case WM_MOVE:
			return (BOOL) !HANDLE_WM_MOVE(hDlg, wParam, lParam, MyWnd_MOVE);
		case WM_CLOSE:
			return (BOOL) !HANDLE_WM_CLOSE(hDlg, wParam, lParam, MyWnd_CLOSE);
		case WM_DESTROY:
			return (BOOL) !HANDLE_WM_DESTROY(hDlg, wParam, lParam, MyWnd_DESTROY);
		default:
			return FALSE;
	}

} // ViewProc */
示例#18
0
BOOL CALLBACK MainDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
    case WM_INITDIALOG:
      return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
    case WM_COMMAND:
      HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
      break;
    case WM_CLOSE:
      DestroyWindow(hWnd);
      break;
    case WM_DESTROY:
      HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
      break;
    case WM_SIZE:
      HANDLE_WM_SIZE(hWnd, wParam, lParam, onSize);
      break;

    default:
      return FALSE;
  }
  return TRUE;
}
示例#19
0
文件: dsksheet.c 项目: mingpen/OpenNT
//==============================================================
//  Disk Sheet Dialog Proc
DLL_EXPORT(BOOL) APIENTRY DiskSheetProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{

	BOOL				*bChanged = (BOOL *)lParam,
						bProcessed = FALSE;

	switch (msg)
	{
		case WM_HELP:
			return((BOOL)OnF1HelpDisk(wParam, lParam));
			break;

		case WM_CONTEXTMENU:
			return((BOOL)OnContextHelpDisk(wParam, lParam));
			break;   

#ifdef WIN32
	case WM_NOTIFY: 
	{
		switch(((NMHDR FAR *)lParam)->code)
		{
		case PSN_HELP:
			WinHelp(hwnd, MSTOR_HELP_FILE, HELP_CONTEXT, IDH_PP_disk);
			break;

	   	case PSN_SETACTIVE:
			if ( !bSheetInitialized )
				OnInitDiskDialog();
			else
				GetFontListAndDisplay(hDisk);
			bSheetInitialized = TRUE;
			bProcessed = TRUE;
			SetWindowLong(hwnd,	DWL_MSGRESULT, FALSE);
			break;

		case PSN_KILLACTIVE:
			bProcessed = TRUE;
			SetWindowLong(hwnd,	DWL_MSGRESULT, FALSE);
	      	break;

	   	case PSN_APPLY:
			bProcessed = TRUE;
			SaveDiskValues();
           	SetWindowLong(hwnd,	DWL_MSGRESULT, PSNRET_NOERROR);
			break;

		case PSN_RESET:
	      	break;

	   	default:
	      	break;
   		}
	}
	break;
#else
			
	//  TabSheet Specific Messages
		case TSN_ACTIVE:
		   if ( !bSheetInitialized )
				OnInitDiskDialog();
		   else
				GetFontListAndDisplay(hDisk);
			bSheetInitialized = TRUE;
			return(TRUE);
			break;

		case TSN_INACTIVE:
		case TSN_OK:
		case TSN_APPLY_NOW:
			*bChanged = TRUE;
			SaveDiskValues();	// added by gfs
			return(TRUE);
			break;

		case TSN_CANCEL:
			return(TRUE);
			break;

		case TSN_HELP:
			WinHelp(hwnd, MSTOR_HELP_FILE, HELP_CONTEXT, IDH_PP_disk);
			break;
#endif // WIN32

		case WM_COMMAND:
			HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnDiskCommand);
			break;

   		case WM_INITDIALOG:
 			bSheetInitialized = FALSE;
      		bProcessed = (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnDiskInitDialog);
			break;
	
		case WM_DESTROY:
			break;
	}
	return (bProcessed);
}
示例#20
0
/*
 * mswin_tw_wndproc() - Main window proc for mswin textwindows.
 */
static LRESULT CALLBACK
mswin_tw_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    MSWIN_TEXTWINDOW *mswin_tw;

    mswin_tw = (MSWIN_TEXTWINDOW *)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA);

    switch(msg)
    {
    case WM_CREATE:
    {
        CREATESTRUCT *pcs = (CREATESTRUCT *)lp;

        mswin_tw = (MSWIN_TEXTWINDOW *)pcs->lpCreateParams;

        MySetWindowLongPtr(hwnd, GWLP_USERDATA, mswin_tw);

        mswin_tw->hwnd_edit = CreateWindowEx(
                        WS_EX_CLIENTEDGE, RICHEDIT_CLASS, 0,
                        WS_VISIBLE | WS_CHILD |
                        WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
                        WS_VSCROLL | WS_HSCROLL |
                        ES_MULTILINE | ES_READONLY | ES_NOHIDESEL,
                        0, 0, 1, 1,
                        hwnd, 0, mswin_tw->hInstance, 0);

        // We want link and key event notifications.
        SendMessage(mswin_tw->hwnd_edit, EM_SETEVENTMASK,
            0, (ENM_KEYEVENTS | ENM_LINK));

        // Specifies the maximum amount of text that can be entered.
        SendMessage(mswin_tw->hwnd_edit, EM_EXLIMITTEXT, 0, g_max_text);

        // Enable automatic detection of URLs by our rich edit control.
        SendMessage(mswin_tw->hwnd_edit, EM_AUTOURLDETECT, TRUE, 0);
        break;
    }

    case WM_CONTEXTMENU:
        mswin_tw_wm_contextmenu(mswin_tw, hwnd, (HWND)wp, GET_X_LPARAM(lp), GET_Y_LPARAM(lp));
        break;

    case WM_NOTIFY:
        return mswin_tw_wm_notify(hwnd, (int)wp, (NMHDR *)lp);

    case WM_COMMAND:
        HANDLE_WM_COMMAND(hwnd, wp, lp, mswin_tw_wm_command);
        break;

    case WM_SETFOCUS:
        SetFocus(mswin_tw->hwnd_edit);
        return TRUE;

    case WM_SIZE:
        MoveWindow(mswin_tw->hwnd_edit, 0, 0, LOWORD(lp), HIWORD(lp), TRUE);
        break;

    case WM_WINDOWPOSCHANGED:
        if(!IsIconic(hwnd))
        {
            WINDOWPOS *wpos = (WINDOWPOS *)lp;

            mswin_tw->rcSize.left = wpos->x;
            mswin_tw->rcSize.top = wpos->y;
            mswin_tw->rcSize.right = wpos->x + wpos->cx;
            mswin_tw->rcSize.bottom = wpos->y + wpos->cy;
        }
        break;

    case WM_DESTROY:
        if(mswin_tw->out_file)
        {
            mswin_tw->out_file_ret = mswin_tw_write_to_file(mswin_tw,
                mswin_tw->out_file);
        }

        mswin_tw->hwnd = NULL;
        mswin_tw->hwnd_edit = NULL;

        if(mswin_tw->close_callback)
            mswin_tw->close_callback(mswin_tw);
        return TRUE;

    default:
        break;
    }

    return DefWindowProc(hwnd, msg, wp, lp);
}
示例#21
0
文件: advanced.c 项目: mingpen/OpenNT
//=========================================================
//  Advanced Sheet Dialog Proc
DLL_EXPORT(BOOL) APIENTRY AdvancedSheetProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam)
{
BOOL				*pChanged = (BOOL *)lParam,
					bProcessed = FALSE;

switch (msg)
	{
#ifdef WIN32
	case WM_HELP:
		return((BOOL)OnF1HelpAdvanced(wParam, lParam));
		break;

	case WM_CONTEXTMENU:
		return((BOOL)OnContextHelpAdvanced(wParam, lParam));
		break;

   	case WM_NOTIFY:
      	switch (((NMHDR FAR *) lParam)->code) 	 
         	{
				case PSN_KILLACTIVE:
      	     	SetWindowLong(hwnd,	DWL_MSGRESULT, FALSE);
					return(TRUE);
					break;

				case PSN_SETACTIVE:
	            	SetWindowLong(hwnd,	DWL_MSGRESULT, FALSE);
					PostMessage(hAdvanced, WM_COMMAND, MAKEWPARAM((UINT)(IDC_SETTINGS_LIST),
		   			         (UINT)(LBN_SELCHANGE)), (LPARAM)(HWND)(hSettingsListbox));
					return(TRUE);
					break;

				case PSN_HELP:
					WinHelp(hwnd, PRINTER_HELP_FILE, HELP_CONTEXT, IDH_PP_advanced);
					return(TRUE);

				case PSN_APPLY:
					SaveAdvancedValues(msg, wParam, lParam);
		        	SetWindowLong(hwnd,	DWL_MSGRESULT, PSNRET_NOERROR);
					return(TRUE);
					break;

				default:
					return(FALSE);
				}
#else
	//  TabSheet Specific Messages
		case TSN_INACTIVE:
			*pChanged = TRUE;
			return(TRUE);
			break;

		case TSN_ACTIVE:
		case TSN_CANCEL:
			PostMessage(hAdvanced, WM_COMMAND, IDC_SETTINGS_LIST, MAKELPARAM(hSettingsListbox, LBN_SELCHANGE));
			return(TRUE);
			break;

		case TSN_OK:
		case TSN_APPLY_NOW:
			SaveAdvancedValues(msg, wParam, lParam);
			break;

		case TSN_HELP:
			WinHelp(hwnd, PRINTER_HELP_FILE, HELP_CONTEXT, IDH_PP_advanced);
			break;
#endif

	case WM_DESTROY:
		HANDLE_WM_DESTROY(hwnd, wParam, lParam, Cls_OnAdvDestroy);
		break;

	case WM_COMMAND:
		HANDLE_WM_COMMAND( hwnd, wParam, lParam, Cls_OnAdvCommand);
		break;

   case WM_INITDIALOG:
		{
     	HCURSOR hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
     	bProcessed = (BOOL)HANDLE_WM_INITDIALOG( hwnd, wParam, lParam, Cls_OnAdvInitDialog);
     	SetCursor(hCursor);
		}
		break;

	case WM_COMPAREITEM:
		return((BOOL)HANDLE_WM_COMPAREITEM(hSettingsListbox, wParam, lParam, Cls_OnCompareItem));
		break;

	case WM_DRAWITEM:
		HANDLE_WM_DRAWITEM(hSettingsListbox, wParam, lParam, Cls_OnLBDrawItem);
		break;

	case WM_MEASUREITEM:
		HANDLE_WM_MEASUREITEM(hSettingsListbox, wParam, lParam, Cls_OnLBMeasureItem);
		break;
	}
return (bProcessed);
}
示例#22
0
文件: trays.c 项目: mingpen/OpenNT
//--------------------------------------------------------------------
// Function:    TraysProc
// 
// Description: 
//
// Input:       hwnd    - 
//              uMsg    - 
//              wParam  - 
//              lParam  - 
//              
// Modifies:    
//
// Returns:     
//
//--------------------------------------------------------------------
DLL_EXPORT(BOOL) APIENTRY TraysProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    BOOL    *pChanged = (BOOL *)lParam;
    
    switch (uMsg)
    {
      case WM_INITDIALOG:
        return (BOOL)HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, Cls_OnTrayInitDialog);
        
      case WM_COMMAND:
        HANDLE_WM_COMMAND(hwnd, wParam, lParam, Cls_OnTrayCommand);
        break;

      case WM_MEASUREITEM:
        HANDLE_WM_MEASUREITEM(hwnd, wParam, lParam, Cls_OnMeasureItem);
        break;

      case WM_DRAWITEM:
        HANDLE_WM_DRAWITEM(hwnd, wParam, lParam, Cls_OnDrawItem);
        break;
        
      case WM_HELP:
        return (BOOL)OnF1HelpTrays(wParam, lParam);
    
      case WM_CONTEXTMENU:
        return (BOOL)OnContextHelpTrays(wParam, lParam);
    
#ifdef WIN32
      case WM_NOTIFY:
        switch (((NMHDR FAR *)lParam)->code)
        {
          case PSN_HELP:
            WinHelp(hwnd, ECL_HELP_FILE, HELP_CONTEXT, IDH_PP_trays);
            break;
    
          case PSN_SETACTIVE:
            SetWindowLong(hwnd,    DWL_MSGRESULT, FALSE);
            return TRUE;
            break;

          case PSN_KILLACTIVE:
            SetWindowLong(hwnd,    DWL_MSGRESULT, FALSE);
            return TRUE;
            break;
    
          case PSN_APPLY:
              SaveTrayValues(hwnd);
              SetWindowLong(hwnd,    DWL_MSGRESULT, PSNRET_NOERROR);
            return TRUE;
            break;
    
          case PSN_RESET:
            break;
    
          default:
              return FALSE;
        }
        break;
#else
    
      case TSN_CANCEL:
          break;

      case TSN_ACTIVE:
          OnActivateDialog(hwnd);
        break;
    
      case TSN_INACTIVE:
        *pChanged = TRUE;
        break;
    
      case TSN_OK:
      case TSN_APPLY_NOW:
          SaveTrayValues(hwnd);
        *pChanged = TRUE;
        break;
    
      case TSN_HELP:
        WinHelp(hwnd, ECL_HELP_FILE, HELP_CONTEXT, IDH_PP_trays);
        break;
#endif // WIN32

      default:
          return FALSE;
    }

    return TRUE;
}
LRESULT CALLBACK MainWindow::MainWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HDC hdc_mem;
	static HDC hdc;
	static PAINTSTRUCT ps;
	static SCROLLINFO si;
	static TEXTMETRIC tm;
	static HPEN strokePen = CreatePen(PS_SOLID, 1, RGB(255,0,0));

	//Static variables for drawing
	static bool isDrawing = FALSE;
	static int StartX, StartY;
	static int EndX, EndY;
	static UINT iButtonState;

	//Static variables for mouse Co-ordinates
	static int xMouse, yMouse;
	xMouse = GET_X_LPARAM(lParam);
	yMouse = GET_Y_LPARAM(lParam);
	static HBRUSH newbrush;

	//Child Window Handles
	MainWindow create;
	RECT rect;

	// Size and position variables
	static int iSysWidth;
	static int iSysHeight;
	static int iWinWidth;
	static int iWinHeight;
	static int cxChar;
	static int cyChar;

	static int iWidth  = 60;   // Button width
	static int iHeight = 30;   // Button height

	static int iListBoxWidth = 300;
	static int iListBoxHeight = 360;

	// Size and position variables
	static int x, y;

	hdc = GetDC(hwnd);
	GetTextMetrics(hdc, &tm);
	cxChar = tm.tmAveCharWidth;
	cyChar = tm.tmHeight;
	ReleaseDC(hwnd, hdc);

	//for Bezier
	static POINT apt[4];

	//bool variables
	bool white = false;
	bool green = false;
	bool red = false;
	bool black = false;

	hProgramInstance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE);

	HBITMAP logo = NULL;
	BITMAP  bitmap;
	logo = (HBITMAP)LoadImage(hProgramInstance, L"standard.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	GetObject(logo, sizeof(bitmap), &bitmap);

	switch (msg)
	{
	case WM_CREATE:
		{
			create.Create(hProgramInstance,hwnd,lParam,logo);
			Exo.CreateStandardToolbar(hwnd, Exo.m_hInstance);
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDC_MAINCURSOR, TBSTATE_CHECKED | TBSTATE_ENABLED);	
		}
		break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO pInfo = (LPMINMAXINFO) lParam;
			pInfo -> ptMaxTrackSize.x = 450;
			pInfo -> ptMaxTrackSize.y = 650;	
		}
		break;

	case WM_SIZE:

		iWidth  = LOWORD(lParam);
		iHeight = HIWORD(lParam);

		// Set vertical scroll bar range and page size
		si.cbSize = sizeof(si);
		si.fMask = SIF_RANGE | SIF_PAGE;
		si.nMin = 0;
		si.nMax = ((iMinWindowHeight - 70) / cyChar);
		si.nPage = iHeight / cyChar;
		SetScrollInfo(hwnd, SB_VERT, &si, TRUE);

		// Set horizontal scroll bar range and page size
		si.cbSize = sizeof(si);
		si.fMask = SIF_RANGE | SIF_PAGE;
		si.nMin = 0;
		si.nMax = ((iMinWindowWidth - 20) / cxChar);
		si.nPage = iWidth / cxChar;
		SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);

		//Child window reposition
		MoveWindow(hwndButton,20,510,iListBoxWidth+90, iListBoxHeight-335, TRUE);
		MoveWindow(hwndWidthSlider, 20, 35, iListBoxWidth - 150, 10, TRUE);
		MoveWindow(hwndFillColor, 260, 35, iListBoxWidth - 150, 10, TRUE);
		GetWindowRect(hwnd, &rect);
		iWinWidth = rect.right - rect.left;
		iWinHeight = rect.bottom - rect.top;
		iSysWidth = GetSystemMetrics(SM_CXSCREEN);
		iSysHeight = GetSystemMetrics(SM_CYSCREEN);

		apt[0].x = iWidth / 7 ;
		apt[0].y = iHeight / 2 ;

		apt[1].x = iWidth / 5;
		apt[1].y = iHeight / 7 ;

		apt[2].x =     iWidth / 2 ;
		apt[2].y = 3 * iHeight / 4 ;

		apt[3].x = 3 * iWidth / 4 ;
		apt[3].y =     iHeight / 2 ;

		break;

	case WM_VSCROLL:
		// Get all the vertical scroll bar information
		si.cbSize = sizeof(si);
		si.fMask = SIF_ALL;
		GetScrollInfo(hwnd, SB_VERT, &si);

		// Save the position for later comparison
		y = si.nPos;

		switch(LOWORD(wParam))
		{
		case SB_TOP:
			si.nPos = si.nMin;
			break;

		case SB_BOTTOM:
			si.nPos = si.nMax;
			break;

		case SB_LINEUP:
			si.nPos -= 1;
			break;

		case SB_LINEDOWN:
			si.nPos += 1;
			break;

		case SB_PAGEUP:
			si.nPos -= si.nPage;
			break;

		case SB_PAGEDOWN:
			si.nPos += si.nPage;
			break;

		case SB_THUMBTRACK:
			si.nPos = si.nTrackPos;
			break;

		default:
			break;
		}

		// Set the position and then retrieve it
		si.fMask = SIF_POS;
		SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
		GetScrollInfo(hwnd, SB_VERT, &si);

		// If the position has changed, scroll the window and update it
		if(si.nPos != y) 
		{
			ScrollWindow(hwnd, 0, cyChar * (y - si.nPos), NULL, NULL);
			UpdateWindow(hwnd);
		}
		break;

	case WM_CTLCOLORSTATIC:

		SetTextColor((HDC)wParam, RGB(150, 100, 255));
		SetBkMode((HDC)wParam, TRANSPARENT);
		newbrush = (HBRUSH)GetStockObject(NULL_BRUSH);
		DeleteObject(newbrush);
		return (LRESULT)newbrush;
		break;

	case WM_HSCROLL:
		GetWindowRect(hwnd, &rect);
		iWinWidth = rect.right - rect.left;
		iWinHeight = rect.bottom - rect.top;
		iSysWidth = GetSystemMetrics(SM_CXSCREEN);
		iSysHeight = GetSystemMetrics(SM_CYSCREEN);

		// Get all the vertical scroll bar information
		si.cbSize = sizeof(si);
		si.fMask = SIF_ALL;
		GetScrollInfo(hwnd, SB_HORZ, &si);

		// Save the position for later comparison
		x = si.nPos;

		if(GetWindowLong((HWND)lParam, GWL_ID) == IDC_BACKGROUND_SCROLL)
		{
			switch(LOWORD(wParam))
			{
			case SB_PAGEDOWN:
				alfa += DELTA_COLOR;
				break;

			case SB_LINEDOWN:
				alfa = min(255, alfa+1);
				break;

			case SB_PAGEUP:
				alfa -= DELTA_COLOR;
				break;

			case SB_LINEUP:
				alfa = max(0, alfa-1);
				break;

			case SB_TOP:
				alfa = 0;
				break;

			case SB_BOTTOM:
				alfa = 255;
				break;

			case SB_THUMBPOSITION:
				break;

			case SB_THUMBTRACK:
				alfa = HIWORD(wParam);
				break;

			default: break;
			}
			SetScrollPos(hwndWidthSlider, SB_CTL, alfa, TRUE);
		}

		if(GetWindowLong((HWND)lParam, GWL_ID) == IDC_FILL_COLOR)
		{
			switch(LOWORD(wParam))
			{
			case SB_PAGEDOWN:
				fill += DELTA_COLOR;
				break;

			case SB_LINEDOWN:
				fill = min(255, fill+1);
				break;

			case SB_PAGEUP:
				fill -= DELTA_COLOR;
				break;

			case SB_LINEUP:
				fill = max(0, fill-1);
				break;

			case SB_TOP:
				fill = 0;
				break;

			case SB_BOTTOM:
				fill = 255;
				break;

			case SB_THUMBPOSITION:
				break;

			case SB_THUMBTRACK:
				fill = HIWORD(wParam);
				break;

			default: break;
			}
			SetScrollPos(hwndFillColor, SB_CTL, fill, TRUE);
		}

		switch(LOWORD(wParam)) 
		{
			case SB_LINELEFT:
				si.nPos -= 1;
				break;

			case SB_LINERIGHT:
				si.nPos += 1;
				break;

			case SB_PAGELEFT:
				si.nPos -= si.nPage;
				break;

			case SB_PAGERIGHT:
				si.nPos += si.nPage;
				break;

			case SB_THUMBPOSITION:
				si.nPos = si.nTrackPos;
				break;

		default:break;
		}

		// Set the position and then retrieve it
		si.fMask = SIF_POS;
		SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
		GetScrollInfo(hwnd, SB_HORZ, &si);
		// If the position has changed, scroll the window and update it
		if(si.nPos != x)
		{
			ScrollWindow(hwnd, cxChar * (x - si.nPos), 0, NULL, 0);
			UpdateWindow(hwnd);
		}
		break;

	case WM_COMMAND:

		//Initialazing OnCommand Function
		HANDLE_WM_COMMAND(hwnd, wParam, lParam, OnCommand);

		switch(LOWORD(wParam))
		{
		case IDC_CLEAR:
			{
				//Cleaning the working area
				InvalidateRect(hwnd, &Recto, FALSE);
				InvalidateRect(hwnd, &Recto, TRUE);
			}
			break;

		case IDM_FILE_NEW:

			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_FILE_NEW, TBSTATE_CHECKED | TBSTATE_ENABLED);
			white = TRUE;
			break;

		case IDM_FILE_OPEN:

			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_FILE_OPEN, TBSTATE_CHECKED | TBSTATE_ENABLED);
			green = TRUE;
			break;

		case IDM_FILE_SAVE:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_FILE_SAVE, TBSTATE_CHECKED | TBSTATE_ENABLED);
			black = TRUE;
			break;

		case IDM_FILE_PRINT:
			red = TRUE;
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_FILE_PRINT, TBSTATE_CHECKED | TBSTATE_ENABLED);

			break;

		case IDM_FILE_EXIT:
			PostQuitMessage(WM_QUIT);
			break;

		case IDM_DRAW_FREEHAND:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_FREEHAND, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_FREEHAND));
			break;
		case IDM_DRAW_LINE:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_LINE, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_FREEHAND));
			break;

		case IDM_DRAW_POLYLINE:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_POLYLINE, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_FREEHAND));
			break;
		case IDM_DRAW_RECTANGLE:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_RECTANGLE, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_RECTANGLE));
			break;

		case IDM_DRAW_CIRCLE:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_CIRCLE, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_CIRCLE));
			break;

		case IDM_DRAW_BEZIER:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_DRAW_BEZIER, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_CIRCLE));
			myBezier.DrawBezier(hdc, apt);
			break;

		case IDM_ERAZER:
			SendMessage(Exo.hWndToolbar, TB_SETSTATE, IDM_ERAZER, TBSTATE_CHECKED | TBSTATE_ENABLED);
			Exo.ChangeCurrentCursor(hwnd, MAKEINTRESOURCE(IDC_ERAZER));
			break;
		}
		break;

		//The following 3 cases are for drawing lines in my drawing area
	case WM_LBUTTONDOWN:


		if (xMouse > 20 && xMouse < 410 && yMouse > 50 && yMouse < 500 )
		{
			//Draw freehand
			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_FREEHAND, 0) & TBSTATE_CHECKED )
			{
				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen,RGB(0,0,255), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);

				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);

				SetROP2(hdc, R2_XORPEN);

				MoveToEx(hdc, StartX, StartY, NULL);
				LineTo(hdc, EndX, EndY);
				isDrawing = TRUE;
				ReleaseDC(hwnd, hdc);
				Exo.DeleteObjectHPEN(strokePen);
			}

			// If the Line button is down, draw with it
			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_LINE, 0) & TBSTATE_CHECKED )
			{
				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);

				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);
				MoveToEx(hdc, StartX, StartY, NULL);
				LineTo(hdc, EndX, EndY);
			}

			//Draw PolyLines
			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_POLYLINE, 0) & TBSTATE_CHECKED )
			{
				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);

				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);
				MoveToEx(hdc, StartX, StartY, NULL);
				LineTo(hdc, EndX, EndY);
			}

			//Draw Rectangle
			if((SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_RECTANGLE, 0) & TBSTATE_CHECKED))
			{
				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);
				SetBkMode(hdc,TRANSPARENT);
				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);
				SetROP2(hdc, R2_NOP);

				MoveToEx(hdc, StartX, StartY, NULL);
				Rectangle(hdc, StartX, StartY, EndX, EndY);
				ReleaseDC(hwnd, hdc);
			}

			//Draw Circle
			if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_CIRCLE, 0) & TBSTATE_CHECKED)
			{
				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
					Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);
				SetBkMode(hdc,TRANSPARENT);
				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);
				SetROP2(hdc, R2_NOP);

				MoveToEx(hdc, StartX, StartY, NULL);
				Ellipse(hdc, StartX, StartY, EndX, EndY);
				ReleaseDC(hwnd, hdc);
			}

			//Eraser
			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_ERAZER, 0) & TBSTATE_CHECKED )
			{
				strokePen = CreatePen(PS_SOLID, alfa, RGB(246, 245, 243));
				SelectObject(hdc, strokePen);
				hdc = GetDC(hwnd);
				StartX = LOWORD(lParam);
				StartY = HIWORD(lParam);

				EndX = LOWORD(lParam);
				EndY = HIWORD(lParam);

				SetROP2(hdc, R2_XORPEN);

				MoveToEx(hdc, StartX, StartY, NULL);
				LineTo(hdc, EndX, EndY);
				isDrawing = TRUE;
				ReleaseDC(hwnd, hdc);
				DeleteObject(strokePen);
			}
			isDrawing = TRUE;
			ReleaseDC(hwnd, hdc);
		}
		break;

	case WM_MOUSEMOVE:

		if (xMouse > 20 && xMouse < 410 && yMouse > 50 && yMouse < 500 )
		{
			hdc = GetDC(hwnd);
			if(isDrawing == TRUE )
			{
				if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_LINE, 0) & TBSTATE_CHECKED )
				{
					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

					SetROP2(hdc, R2_NOTXORPEN);
					MoveToEx(hdc, StartX, StartY, NULL);
					LineTo(hdc, EndX, EndY);
					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);
					MoveToEx(hdc, StartX, StartY, NULL);
					LineTo(hdc, EndX, EndY);						
				}				

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_FREEHAND, 0) & TBSTATE_CHECKED )
				{
					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

					MoveToEx(hdc, EndX, EndY, NULL);
					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);
					LineTo(hdc, EndX, EndY);
				}

				if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_POLYLINE, 0) & TBSTATE_CHECKED )

				{
					if(wParam & MK_RBUTTON)
						isDrawing = false;

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);

					MoveToEx(hdc, StartX, StartY, NULL);
					LineTo(hdc, EndX, EndY);;
				}

				if((SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_RECTANGLE, 0) & TBSTATE_CHECKED))
				{

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);

					HBRUSH brush = CreateSolidBrush(RGB(fill,fill-100,145));
					SelectObject(hdc, brush);

					SetROP2(hdc, R2_NOTXORPEN);
					SetBkMode(hdc,TRANSPARENT);
					MoveToEx(hdc, StartX, StartY, NULL);
					Rectangle(hdc, StartX, StartY, EndX, EndY);
					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);
					MoveToEx(hdc, StartX, StartY, NULL);
					Rectangle(hdc, StartX, StartY, EndX, EndY);
					DeleteObject(brush);
				}

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_CIRCLE, 0) & TBSTATE_CHECKED)
				{
					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,255), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,255,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(0,0,0), alfa);

					if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED)
						Exo.ChangeCurrentColor(hdc,strokePen, RGB(255,0,0), alfa);


					HBRUSH brush = CreateSolidBrush(RGB(fill,fill-100,145));
					SelectObject(hdc, brush);

					SetROP2(hdc, R2_NOTXORPEN);
					MoveToEx(hdc, StartX, StartY, NULL);
					Ellipse(hdc, StartX, StartY, EndX, EndY);
					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);
					MoveToEx(hdc, StartX, StartY, NULL);
					Ellipse(hdc, StartX, StartY, EndX, EndY);
					DeleteObject(brush);
				}

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_BEZIER, 0) & TBSTATE_CHECKED)
				{
					if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
					{
						HGDIOBJ original = NULL;

						//Saving the original object
						original = SelectObject(hdc,GetStockObject(DC_PEN));
						SelectObject(hdc, GetStockObject(DC_PEN));
						SetDCPenColor(hdc, RGB(246, 245, 243));
						myBezier.DrawBezier (hdc, apt) ;

						if (wParam & MK_LBUTTON)
						{
							apt[1].x = LOWORD (lParam) ;
							apt[1].y = HIWORD (lParam) ;
						}

						else  if (wParam & MK_RBUTTON)
						{
							apt[2].x = LOWORD (lParam) ;
							apt[2].y = HIWORD (lParam) ;
						}

						SelectObject (hdc, GetStockObject(BLACK_PEN)) ;
						myBezier.DrawBezier (hdc, apt) ;
						ReleaseDC (hwnd, hdc) ;
						DeleteObject(original);
					}
				}

				if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_ERAZER, 0) & TBSTATE_CHECKED )
				{
					strokePen = CreatePen(PS_SOLID, alfa, RGB(246, 245, 243));
					SelectObject(hdc, strokePen);
					MoveToEx(hdc, EndX, EndY, NULL);
					EndX = LOWORD(lParam);
					EndY = HIWORD(lParam);
					LineTo(hdc, EndX, EndY);
					Exo.DeleteObjectHPEN(strokePen);
				}
			}
			ReleaseDC(hwnd, hdc);
		}
		break;

	case WM_LBUTTONUP:

		if (xMouse > 20 && xMouse < 410 && yMouse > 50 && yMouse < 500 )
		{
			hdc = GetDC(hwnd);
			EndX = LOWORD(lParam);
			EndY = HIWORD(lParam);
			SetROP2(hdc, R2_XORPEN);
			MoveToEx(hdc, StartX, StartY, NULL);
			LineTo(hdc, EndX, EndY);

			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_NEW, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
				white = FALSE;
			}

			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_OPEN, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
				green = FALSE;
			}

			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_SAVE, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
				black = FALSE;
			}

			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_FILE_PRINT, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
				red = FALSE;
			}


			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_LINE, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
			}

			if( SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_POLYLINE, 0) & TBSTATE_CHECKED)
			{
				isDrawing = FALSE;
			}

			if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_FREEHAND, 0) & TBSTATE_CHECKED )
			{
				isDrawing = FALSE;
			}

			if((SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_RECTANGLE, 0) & TBSTATE_CHECKED))
			{
				SetBkMode(hdc,TRANSPARENT);
				Rectangle(hdc, StartX, StartY, EndX, EndY);
				isDrawing = FALSE;
			}

			if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_CIRCLE, 0) & TBSTATE_CHECKED)
			{
				isDrawing = FALSE;
			}

			if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_DRAW_BEZIER, 0) & TBSTATE_CHECKED)
			{
				isDrawing = FALSE;
			}

			if(SendMessage(Exo.hWndToolbar, TB_GETSTATE, IDM_ERAZER, 0) & TBSTATE_CHECKED)
			{
				isDrawing = FALSE;
			}

			ReleaseDC(hwnd, hdc);
		}
		break;

	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		GetClientRect(hwnd , &rect);
		hdc_mem = CreateCompatibleDC(hdc);
		SelectObject(hdc_mem, logo);
		BitBlt(hdc, 15, 540, bitmap.bmWidth, bitmap.bmHeight, hdc_mem, 0, 0, SRCCOPY);

		DeleteObject(hdc_mem);
		//Creating Draw Area
		DrawEdge(hdc, &Recto, BDR_RAISEDOUTER | BDR_SUNKENINNER, BF_RECT);

		EndPaint(hwnd, &ps);
		break;

		//Handle the combinations from the keyboard input
	case WM_KEYDOWN:
		{
			switch(wParam)
			{
			case KEY_S:
				isDrawing = FALSE;
				break;
			case KEY_Q:
				{
					if(GetAsyncKeyState(VK_LCONTROL))
					{
						//If Q + LCTRL then Exit
						PostQuitMessage(0);
					}
				}
				break;

			case KEY_C:
				{
					if(GetAsyncKeyState(VK_LSHIFT))
					{
						//If C + LShift then cleaning the drawingarea
						InvalidateRect(hwnd, &Recto, FALSE);
						InvalidateRect(hwnd, &Recto, TRUE);

					}
				}
				break;
			}
		}
		break;

	case WM_DESTROY:
		PostQuitMessage (0);
		DeleteObject(logo);
		DeleteObject(strokePen);
		break;

	default:
		return DefWindowProc (hwnd, msg, wParam, lParam);
	}

	return 0;
}
示例#24
0
LRESULT CALLBACK EXPORT AWLayoutWndProc
  (
  HWND    hwnd,
  UINT    uMsg,
  WPARAM  wParam,
  LPARAM  lParam
  )

  {
  BOOL    fHandled = FALSE;
  LRESULT lRet;
  Layout* pLayout = (Layout*)GetWindowLong(hwnd, I_GWL_LAYOUT);

  switch(uMsg)
    {
    case WM_CREATE:
      pLayout = (Layout*)(((CREATESTRUCT*)lParam)->lpCreateParams);
      SetWindowLong(hwnd, I_GWL_LAYOUT, (long)pLayout);
      pLayout->m_hwndLayout = hwnd;
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_SYSCOMMAND:
      if((wParam & 0xFFF0)==SC_CLOSE)
        {
        FORWARD_WM_COMMAND(hwnd, IDM_EXIT, 0, 0, PostMessage);
        fHandled = TRUE;
        lRet = 0L;
        break;
        }
      break;

    case WM_QUERYENDSESSION:
      MessageBeep(MB_ICONEXCLAMATION);
      MessageBox(hwnd, "Window layout is still active.\r\n\r\nQuit the window layout before quitting Windows.", "Window Layout", MB_TASKMODAL | MB_OK | MB_ICONEXCLAMATION);
      lRet = 0;
      fHandled = TRUE;
      break;

    case WM_KEYDOWN:
      (pLayout->m_shapes).KeyDown(pLayout->m_pWndActive, hwnd, (int)wParam, lParam);
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_KEYUP:
      (pLayout->m_shapes).KeyUp(pLayout->m_pWndActive, hwnd, (int)wParam, lParam);
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_INITMENUPOPUP:
      HANDLE_WM_INITMENUPOPUP(hwnd, wParam, lParam, pLayout->InitMenuPopup);
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_PALETTECHANGED:
      if ((pLayout->ActiveWindow()) && ((HWND)wParam==pLayout->ActiveWindow()->ClientWnd()))
        break;
      // else fall through
    case WM_QUERYNEWPALETTE:
      if(!IsIconic(hwnd) && pLayout->ActiveWindow() && WndData::GetPaletteHandle())
        {
        HDC       hdc     = GetDC(pLayout->ActiveWindow()->ClientWnd());
        HPALETTE  hpalOld = SelectPalette(hdc, WndData::GetPaletteHandle(), FALSE);
        lRet = RealizePalette(hdc);         
        SelectPalette(hdc, hpalOld, TRUE);
        RealizePalette(hdc);
        ReleaseDC(pLayout->ActiveWindow()->ClientWnd(), hdc);

        if(lRet)                            
          InvalidateRect(pLayout->ActiveWindow()->ClientWnd(), NULL, TRUE);
        fHandled = TRUE;
        }
      break;

    case WM_HSCROLL:
      HANDLE_WM_HSCROLL(hwnd, wParam, lParam, pLayout->HScroll);
      fHandled = TRUE;
      lRet = 0;
      break;

    case WM_VSCROLL:
      HANDLE_WM_VSCROLL(hwnd, wParam, lParam, pLayout->VScroll);
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_SIZE:
      pLayout->UpdateScrollRegion();
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_COMMAND:
      HANDLE_WM_COMMAND(hwnd, wParam, lParam, pLayout->Command);
      fHandled = TRUE;
      lRet = 0L;
      break;

    case WM_NCACTIVATE:
      if(!IsIconic(hwnd) && pLayout->m_pWndActive && pLayout->m_pWndActive->WndHandle())
        SendMessage(pLayout->m_pWndActive->WndHandle(), uMsg, wParam, lParam);
      break;

    default:
      break;
    }

  if(!fHandled)
    lRet = DefWindowProc(hwnd, uMsg, wParam, lParam);

  return lRet;
  }