Exemplo n.º 1
0
LRESULT
CounterOnInitDialog(
	IN HWND hWnd,
	IN UINT uMsg,
	IN WPARAM wp,
	IN LPARAM lp
	)
{
	PDIALOG_OBJECT Object;
	PCOUNTER_CONTEXT Context;
	PTREELIST_OBJECT TreeList;
	PMSP_DTL_OBJECT DtlObject;
	HWND hWndRect;
	HWND hWndDesktop;
	RECT Rect;
	TVINSERTSTRUCT tvi = {0};
	ULONG Number;
	ULONG NumberOfGroups;

	Object = (PDIALOG_OBJECT)SdkGetObject(hWnd);
	Context = SdkGetContext(Object, COUNTER_CONTEXT);
	DtlObject = Context->DtlObject;

	hWndDesktop = GetDesktopWindow();
	hWndRect = GetDlgItem(hWnd, IDC_TREE_RECT);
	GetWindowRect(hWndRect, &Rect);
	MapWindowRect(hWndDesktop, hWnd, &Rect);

	ShowWindow(hWndRect, SW_HIDE);

	TreeList = TreeListCreate(hWnd, TRUE, IDC_TREE_COUNTER, 
							  &Rect, hWnd, 
							  CounterFormatCallback, 
							  CounterColumnCount);

	Context->TreeList = TreeList;

	for(Number = 0; Number < CounterColumnCount; Number += 1) {
		TreeListInsertColumn(TreeList, Number, 
			                 CounterColumn[Number].Align, 
							 CounterColumn[Number].Width, 
							 CounterColumn[Number].Name );
	}

	SetWindowText(hWnd, L"Probe Summary");
	SdkSetMainIcon(hWnd);

	NumberOfGroups = CounterInsertGroup(Object);
	if (!NumberOfGroups) {
		return TRUE;
	}

	if (DtlObject->Type != DTL_REPORT) {
		Context->TimerId = SetTimer(hWnd, COUNTER_TIMER_ID, 1000, NULL);
	} else {
		CounterUpdate(TreeList);
	}

	return TRUE;
}
Exemplo n.º 2
0
static void GetDlgCtlRect(
	HWND    hwndDlg,
	int     nID,
	LPRECT  lprc)
{
  GetWindowRect(GetDlgItem(hwndDlg, nID), lprc);
  MapWindowRect(NULL, hwndDlg, lprc);
}
Exemplo n.º 3
0
void NEAR PASCAL unachor(PUDSTATE np)
{
    RECT rc;
    RECT rcBuddy;
    RECT rcUD;

    if ( np->hwndBuddy && (np->ci.style & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT))) {
        GetWindowRect(np->hwndBuddy, &rcBuddy);
        GetWindowRect(np->ci.hwnd, &rcUD);
        UnionRect(&rc, &rcUD, &rcBuddy);
        MapWindowRect(NULL, np->ci.hwndParent, &rc);
        MoveWindow(np->hwndBuddy, rc.left, rc.top,
                                rc.right - rc.left, rc.bottom - rc.top, FALSE);

    }
}
Exemplo n.º 4
0
VOID 
SdkCopyControlRect(
    IN HWND hWndParent,
    IN HWND hWndFrom,
    IN HWND hWndTo
    )
{
	HWND hWndDesktop;
    RECT Rect;

	hWndDesktop = GetDesktopWindow();
    GetWindowRect(hWndFrom, &Rect);
	MapWindowRect(hWndDesktop, hWndParent, &Rect);
    MoveWindow(hWndTo, Rect.left, Rect.top, 
			   Rect.right - Rect.left, 
			   Rect.bottom - Rect.top, TRUE);
}
Exemplo n.º 5
0
/**
 * @param iPanel - panel number.
 * @param hwndPanel - panel window handle.
 * @return true if panel index is valid.
 */
BOOL CSplitter::SetPanel(int iPanel, HWND hwndPanel)
{
	_ASSERTE(m_hwnd != NULL);
	if (iPanel >= 0 && iPanel < NUM_PANELS)
	{
		m_arrPanels[iPanel] = hwndPanel;
		if (hwndPanel)
		{
			RECT rect;
			CalcPanelRect(iPanel, rect, true);
			HWND hwndPanelParent = GetParent(hwndPanel);
			MapWindowRect(m_hwnd, hwndPanelParent, &rect);
			SetWindowPos(hwndPanel, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
		}
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 6
0
void CDropDownWnd::Init(CDropDownUI* pOwner)
{
	m_pOwner = pOwner;
	m_iOldSel = m_pOwner->GetCurSel();
	// Position the popup window in absolute space
	SIZE szDrop = m_pOwner->GetDropDownSize();
	RECT rc = pOwner->GetPos();
	rc.top = rc.bottom;
	rc.bottom = rc.top + szDrop.cy;
	if( szDrop.cx > 0 ) rc.right = rc.left + szDrop.cx;
	MapWindowRect(pOwner->GetManager()->GetPaintWindow(), HWND_DESKTOP, &rc);
	Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_POPUP | WS_BORDER, WS_EX_TOOLWINDOW, rc);
	// HACK: Don't deselect the parent's caption
	HWND hWndParent = m_hWnd;
	while( ::GetParent(hWndParent) != NULL ) hWndParent = ::GetParent(hWndParent);
	::ShowWindow(m_hWnd, SW_SHOW);
	::SendMessage(hWndParent, WM_NCACTIVATE, TRUE, 0L);
}
Exemplo n.º 7
0
void CSplitter::UpdateLayout(void)
{
	_ASSERTE(m_hwnd != NULL);
	InvalidateRect(m_hwnd, NULL, FALSE);
	HDWP hdwp = BeginDeferWindowPos(NUM_PANELS);
	if (hdwp)
	{
		for (int iPanel = 0; iPanel < NUM_PANELS; ++iPanel)
		{
			HWND hwndPanel = m_arrPanels[iPanel];
			if (hwndPanel)
			{
				RECT rect;
				CalcPanelRect(iPanel, rect, true);
				HWND hwndPanelParent = GetParent(hwndPanel);
				MapWindowRect(m_hwnd, hwndPanelParent, &rect);
				DeferWindowPos(hdwp, hwndPanel, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
			}
		}
		EndDeferWindowPos(hdwp);
	}
}
Exemplo n.º 8
0
void BottomAlignStatic(HWND hStatic)
{
    HWND hParent;
    RECT rc;
    RECT rcStatic;
    int cyText;
    HDC hdc;
    TCHAR szText[512];

    hParent = GetParent(hStatic);
    GetWindowText(hStatic, szText, ARRAYSIZE(szText));

    GetWindowRect(hStatic, &rcStatic);
    MapWindowRect(HWND_DESKTOP, hParent, &rc);

    hdc = GetDC(hStatic);

    // We need to bottom align the prompt text
    SelectObject(hdc, GetWindowFont(hStatic));

    // Ask DrawText for the right cx and cy
    rc.left     = 0;
    rc.top      = 0;
    rc.right    = rcStatic.right - rcStatic.left;
    rc.bottom   = rcStatic.bottom - rcStatic.top;
    cyText = DrawTextEx(hdc, szText, -1, &rc,
            DT_CALCRECT | DT_WORDBREAK | DT_EXPANDTABS |
            DT_NOPREFIX | DT_EXTERNALLEADING, NULL);

    // This should automatically deselect the font
    ReleaseDC(hStatic, hdc);

    if (cyText < rcStatic.bottom-rcStatic.top)
    {
        rcStatic.top = rcStatic.bottom - cyText;
        SetWindowPos(hStatic, NULL, rcStatic.left, rcStatic.top,
                rcStatic.right-rcStatic.left, cyText, SWP_NOZORDER);
    }
}
Exemplo n.º 9
0
void FILETRANSFER::ChangeProtocol(HWND hDlg)
{
	int  index ;
	int  nCurProtocol = data0->fileType ;
	RECT rc ;

	index = (int)SendDlgItemMessage (
																		hDlg,
																		idProto,
																		CB_GETCURSEL,
	 																	0,
																		0L) ;
	if (index != nCurProtocol && index != LB_ERR)
		{
	  SetWindowRedraw(hDlg, FALSE);
		ShowProtocolFrame(
								hDlg, 
								protocolFrame[nCurProtocol].nFirstID,
		      			protocolFrame[nCurProtocol].nLastID, 
		      			FALSE);
    nCurProtocol = index ;
    ShowProtocolFrame(
    						hDlg, 
    						protocolFrame[nCurProtocol].nFirstID,
		      			protocolFrame[nCurProtocol].nLastID, 
		      			TRUE);
    SetWindowRedraw(hDlg, TRUE);
    GetWindowRect(
    							GetDlgItem(hDlg, DLG_FRAME),
						      &rc);
		MapWindowRect(NULL, hDlg, &rc);
		InvalidateRect(hDlg, &rc, TRUE);
		}
	ShowProtocolParam (hDlg, nCurProtocol) ;
	data0->fileType = nCurProtocol ;
}
Exemplo n.º 10
0
INT_PTR DlgMain::dlg_proc(UINT message, WPARAM wParam, LPARAM lParam)
{
static int margin_size = 0;
static bool show_lines = true;
static HWND StatusWindow = NULL;
static HIMAGELIST hImgListTool = NULL;
static HWND ToolWindow = NULL;
static HMENU hMenuFile = NULL, hMenuView = NULL;

	switch(message)
	{
	case WM_INITDIALOG:
		{
		this->hEditor = GetDlgItem(this->window, ScEditor);
		assert(IsWindow(this->hEditor));

		hMenuFile = GetSubMenu(GetMenu(this->window), 0);
		hMenuView = GetSubMenu(GetMenu(this->window), 1);
		assert(IsMenu(hMenuFile));
		assert(IsMenu(hMenuView));

		// We need a custom message loop to add TranslateAccelerator
		// hint: WTL now!!!
		//LoadAccelerators(this->instance, MAKEINTRESOURCE(IDR_ACCELERATOR));

		// Create toolbar
		ToolWindow = CreateWindow(TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, this->window, reinterpret_cast<HMENU>(TbMain), this->instance, NULL); ;//CreateToolbarEx(this->window, WS_VISIBLE | )
		assert(IsWindow(ToolWindow));

		// Declare and initialize local constants.
		const int ImageListID    = 0;
		const int numButtons     = 3;
		const int bitmapSize     = 16;

		const DWORD buttonStyles = BTNS_AUTOSIZE;

		// Create the image list
		hImgListTool = ImageList_Create(bitmapSize, bitmapSize, ILC_COLOR32 | ILC_MASK, numButtons, 0);

		// Set the image list
		SendMessage(ToolWindow, TB_SETIMAGELIST, ImageListID, reinterpret_cast<LPARAM>(hImgListTool));

		// Load the button images
		SendMessage(ToolWindow, TB_LOADIMAGES, IDB_STD_SMALL_COLOR, reinterpret_cast<LPARAM>(HINST_COMMCTRL));

		// Initialize button info
		// IDM_NEW, IDM_OPEN, and IDM_SAVE are application-defined command constants.

		TBBUTTON tbButtons[numButtons] = 
		{
			{ MAKELONG(STD_FILENEW,  ImageListID), IDM_FILE_NEW,  TBSTATE_ENABLED, buttonStyles, {0}, 0, reinterpret_cast<LPARAM>(L"New") },
			{ MAKELONG(STD_FILEOPEN, ImageListID), IDM_FILE_OPEN, TBSTATE_ENABLED, buttonStyles, {0}, 0, reinterpret_cast<LPARAM>(L"Open")},
			{ MAKELONG(STD_FILESAVE, ImageListID), IDM_FILE_SAVE, 0,               buttonStyles, {0}, 0, reinterpret_cast<LPARAM>(L"Save")}
		};

		// Add buttons
		SendMessage(ToolWindow, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
		SendMessage(ToolWindow, TB_ADDBUTTONS, numButtons, reinterpret_cast<LPARAM>(&tbButtons));

		// Resize the toolbar
		SendMessage(ToolWindow, TB_AUTOSIZE, 0, 0);

		RECT toolRect;
		GetClientRect(ToolWindow, &toolRect);
		RECT editRect;
		GetWindowRect(this->hEditor, &editRect);
		MapWindowRect(HWND_DESKTOP, this->window, &editRect);
		
		MoveWindow(this->hEditor, editRect.left, editRect.top + toolRect.bottom, editRect.right - editRect.left, editRect.bottom - editRect.top - toolRect.bottom, false);

		// Create status bar
		StatusWindow = CreateWindow(STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, this->window, reinterpret_cast<HMENU>(SbInfo), this->instance, NULL);
		assert(IsWindow(StatusWindow));
		RECT DlgRect, SbRect;
		GetWindowRect(this->window, &DlgRect); // Increase dialog height to integrate the status bar
		GetClientRect(StatusWindow, &SbRect);
		MoveWindow(this->window, DlgRect.left, DlgRect.top, DlgRect.right-DlgRect.left, DlgRect.bottom-DlgRect.top+SbRect.bottom, true);
		SendMessage(StatusWindow, WM_SIZE, 0, 0); // Force Status bar to reposition

		// Set up lexer
		this->SendEditor(SCI_SETLEXER, SCLEX_CPP);
		this->SendEditor(SCI_SETSTYLEBITS, this->SendEditor(SCI_GETSTYLEBITSNEEDED));

		// Set up line number margin
		this->SendEditor(SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER);
		this->SendEditor(SCI_SETMARGINCURSORN, 0, SC_CURSORARROW);
		margin_size = this->SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, "_1");
		this->SendEditor(SCI_SETMARGINWIDTHN, 0, margin_size);
		show_lines = true;

		// Disable all other margins
		this->SendEditor(SCI_SETMARGINWIDTHN, 1, 0);
		this->SendEditor(SCI_SETMARGINWIDTHN, 2, 0);
		this->SendEditor(SCI_SETMARGINWIDTHN, 3, 0);
		this->SendEditor(SCI_SETMARGINWIDTHN, 4, 0);

		// Set up default color, font, size
		const COLORREF CLR_BLACK = RGB(0,0,0);
		const COLORREF CLR_WHITE = RGB(255,255,255);

		this->SendEditor(SCI_STYLESETFORE, STYLE_DEFAULT, CLR_BLACK);
		this->SendEditor(SCI_STYLESETBACK, STYLE_DEFAULT, CLR_WHITE);
		this->SendEditor(SCI_STYLESETSIZE, STYLE_DEFAULT, 10);
		this->SendEditor(SCI_STYLESETFONT, STYLE_DEFAULT, "Courier New");

		// Set up Lexer colors
		const COLORREF CLR_LGREEN = RGB(0, 128, 0);
		const COLORREF CLR_LBLUE  = RGB(0, 127, 174);

		/*
		String 163, 21, 21 (Rot)
		Stale 128, 0, 128 (Violett)
		Preprocessor 0, 0, 255
		Keyword 0, 0, 255

		Sweet blue 43, 145, 175 / 0, 127, 174
		*/

		this->set_editor_color(SCE_C_DEFAULT, CLR_BLACK);

		this->set_editor_color(SCE_C_COMMENT, CLR_LGREEN);
		this->set_editor_color(SCE_C_COMMENTLINE, CLR_LGREEN);
		this->set_editor_color(SCE_C_COMMENTDOC, CLR_LGREEN);

		//this->set_editor_color(SCE_C_NUMBER, CLR_LBLUE);
		//this->set_editor_color(SCE_C_WORD, CLR_LBLUE);

		this->set_editor_color(SCE_C_STRING, CLR_LBLUE);
		this->set_editor_color(SCE_C_CHARACTER, CLR_LBLUE);

		/*
		this->set_editor_color(SCE_C_UUID, CLR_LBLUE);
		this->set_editor_color(SCE_C_PREPROCESSOR, CLR_LBLUE);
		this->set_editor_color(SCE_C_OPERATOR, CLR_LBLUE);
		this->set_editor_color(SCE_C_IDENTIFIER, CLR_LBLUE);
		this->set_editor_color(SCE_C_STRINGEOL, CLR_LBLUE);
		this->set_editor_color(SCE_C_VERBATIM, CLR_LBLUE);
		this->set_editor_color(SCE_C_REGEX, CLR_LBLUE);
		*/
		this->set_editor_color(SCE_C_COMMENTLINEDOC, CLR_LGREEN);
		
		//this->set_editor_color(SCE_C_WORD2, CLR_LBLUE);

		this->set_editor_color(SCE_C_COMMENTDOCKEYWORD, CLR_LGREEN);
		this->set_editor_color(SCE_C_COMMENTDOCKEYWORDERROR, CLR_LGREEN);
		/*
		this->set_editor_color(SCE_C_GLOBALCLASS, CLR_LBLUE);
		this->set_editor_color(SCE_C_STRINGRAW, CLR_LBLUE);
		this->set_editor_color(SCE_C_TRIPLEVERBATIM, CLR_LBLUE);
		*/

		this->SendEditor(SCI_STYLESETFORE, STYLE_LINENUMBER, CLR_LBLUE);
		//this->SendEditor(SCI_STYLESETBACK, STYLE_LINENUMBER, CLR_WHITE);
		this->SendEditor(SCI_STYLESETSIZE, STYLE_LINENUMBER, 10);
		this->SendEditor(SCI_STYLESETFONT, STYLE_LINENUMBER, "Courier New");

		//SendEditor(SCI_STYLECLEARALL);

		//this->SendEditor(SCI_SETPROPERTY, "lexer.cpp.allow.dollars", "1");

		// compilation errors etc.:
		// SCI_ANNOTATIONSETTEXT
		}
		break;

	case WM_GETMINMAXINFO:
		{
		MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lParam);
		assert(mmi);
		mmi->ptMinTrackSize.x = 400;
		mmi->ptMinTrackSize.y = 400;
		}
		break;

	case WM_SIZING:
		{
		// calculate difference to previous size
		const RECT* rectNew = reinterpret_cast<const RECT*>(lParam);
		assert(rectNew);
		RECT rectOld;
		GetWindowRect(this->window, &rectOld);
		long deltaX = (rectNew->right  - rectNew->left) - (rectOld.right  - rectOld.left);
		long deltaY = (rectNew->bottom - rectNew->top)  - (rectOld.bottom - rectOld.top);
		// resize child window
		RECT rectEditor;
		GetWindowRect(this->hEditor, &rectEditor);
		int cx = rectEditor.right - rectEditor.left + deltaX;
		int cy = rectEditor.bottom - rectEditor.top + deltaY;
		MapWindowRect(HWND_DESKTOP, this->window, &rectEditor);
		MoveWindow(this->hEditor, rectEditor.left, rectEditor.top, cx, cy, false);
		}
		break;

	case WM_SIZE:
		SendMessage(StatusWindow, WM_SIZE, 0, 0); // Force Status bar to reposition
		//SendMessage(ToolWindow, TB_AUTOSIZE, 0, 0);
		//InvalidateRect(this->window, NULL, true);
		break;

	case WM_NOTIFY:
		{
		const NMHDR* nmHdr = reinterpret_cast<const NMHDR*>(lParam);
		assert(nmHdr);
		if(nmHdr->hwndFrom == this->hEditor)
		{
			switch(nmHdr->code)
			{
				case SCN_MODIFIED:
					{
					char buffer[16] = "";
					int lines = this->SendEditor(SCI_GETLINECOUNT);
					assert(lines > 0);
					sprintf(buffer, "_%d", lines);
					margin_size = this->SendEditor(SCI_TEXTWIDTH, STYLE_LINENUMBER, buffer);
					if(show_lines)
						this->SendEditor(SCI_SETMARGINWIDTHN, 0, margin_size);
					}
					break;
				case SCN_SAVEPOINTREACHED:
					SetWindowText(this->window, L"FireFly");
					EnableMenuItem(hMenuFile, IDM_FILE_SAVE, MF_BYCOMMAND | MF_GRAYED);
					break;
				case SCN_SAVEPOINTLEFT:
					SetWindowText(this->window, L"* FireFly");
					EnableMenuItem(hMenuFile, IDM_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
					break;
				default:
					return false;
			}
		}
		else return false;
		}
		break;

	case WM_DROPFILES:
		{
		HDROP hDrop = reinterpret_cast<HDROP>(wParam);
		unsigned int Count = DragQueryFile(hDrop, static_cast<UINT>(-1), 0, 0);
		if(Count > 0)
		{
			wchar_t FileName[MAX_PATH];
			DragQueryFile(hDrop, 0, FileName, _countof(FileName));
			if(!(GetFileAttributes(FileName) & FILE_ATTRIBUTE_DIRECTORY))
			{
				this->SendEditor(SCI_SETTEXT, NULL, "SNAKE");
				// do stuff
			}
		}
		DragFinish(hDrop);
		}
		break;

	case WM_HELP: // F1
		break;

	//case WM_GETDLGCODE:
	//	return DLGC_WANTCHARS;

		/*
		 * I want CTRL+S :(
		 * only sent to windows with focus (= Scintilla)
		 * can't use accelerator (message loop in olly)
		 * can't use RegisterHotKey (might be registered)
		 **/
	case WM_CHAR:
	case WM_KEYDOWN:
		switch(wParam)
		{
		case 'S':
		case 's':
			//this->SendEditor(SCI_SETSAVEPOINT);
			//if(!(lParam & (1 << 30))) //previous key state
			{
				if(GetKeyState(VK_CONTROL)/* & (1 << 15)*/)
				{
					//SendMessage(this->window, WM_COMMAND, )
					this->SendEditor(SCI_SETSAVEPOINT);
					break;
				}
			}
			return false;
		default:
			return false;
		}
		break;

	case WM_COMMAND:
		switch(GET_WM_COMMAND_ID(wParam, lParam))
		{
		case IDM_FILE_NEW:
			{
			bool cancel = false;
			if(this->SendEditor(SCI_GETMODIFY))
			{
				DlgQuestion question(this->window);
				question.show(L"The code has been modified. Save changes?", L"FireFly", DlgQuestion::tWarning, DlgQuestion::cYesNoCancel);
				switch(question.get_result())
				{
				case DlgQuestion::rYes:
					/*
					if(!filename)
					{
						DlgFileSave save(this->instance, this->window);
						save.modal();
						if(save.cancelled())
						{
							cancel = true;
							break;
						}
					}
					save(file);
					*/
				case DlgQuestion::rNo:
					break;
				case DlgQuestion::rCancel:
					cancel = true;
					break;
				}
			}
			if(!cancel)
			{
				this->SendEditor(SCI_CLEARALL);
				this->SendEditor(SCI_SETSAVEPOINT);
				//file = "";
			}
			}
			break;
		case IDM_FILE_OPEN:
			{
				/*
			int len = this->SendEditor(SCI_GETLENGTH) + 1;
			assert(len > 0);
			const char* buf = new char[len];
			this->SendEditor(SCI_GETTEXT, len, buf);
			this->interface.run_script(buf);
			delete[] buf;
			*/
			//DlgFileOpen open(this->instance, this->window);
			//open.modal();
			//filename = ??
			//this->SendEditor(SCI_SETTEXT, NULL, text);
			}
			break;
		case IDM_FILE_SAVE:
			//if(!filename)
			//{
			//DlgFileSave save(this->instance, this->window);
			//save.modal();
			//filename = ??
			//}
			//assert(this->SendEditor(SCI_GETMODIFY));
			this->SendEditor(SCI_SETSAVEPOINT);
			break;
		case IDM_FILE_CLOSE:
			{
			bool cancel = false;
			if(this->SendEditor(SCI_GETMODIFY))
			{
				DlgQuestion question(this->window);
				question.show(L"The code has been modified. Save changes?", L"FireFly", DlgQuestion::tWarning, DlgQuestion::cYesNoCancel);
				switch(question.get_result())
				{
				case DlgQuestion::rYes:
					/*
					if(!filename)
					{
						DlgFileSave save(this->instance, this->window);
						save.modal();
						if(save.cancelled())
						{
							cancel = true;
							break;
						}
					}
					save(file);
					*/
				case DlgQuestion::rNo:
					break;
				case DlgQuestion::rCancel:
					cancel = true;
					break;
				}
			}
			if(!cancel)
				SendMessage(this->window, WM_CLOSE, 0, 0);
			}
			break;

		case IDM_OPTIONS_FONT:
			break;
		case IDM_OPTIONS_COLORS:
			break;

		case IDM_VIEW_LINENUMBERS:
			bool checked;
			checked = ((GetMenuState(hMenuView, IDM_VIEW_LINENUMBERS, MF_BYCOMMAND) & MF_CHECKED) == MF_CHECKED);
			show_lines = !checked;
			CheckMenuItem(hMenuView, IDM_VIEW_LINENUMBERS, MF_BYCOMMAND | (show_lines ? MF_CHECKED : MF_UNCHECKED));
			this->SendEditor(SCI_SETMARGINWIDTHN, 0, (show_lines ? margin_size : 0));
			break;

		case IDM_HELP_HELP:
			break;
		case IDM_HELP_ABOUT:
			{
			DlgAbout about(this->instance, this->window);
			about.modal();
			}
			break;

		default:
			return false;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(StatusWindow);
		DestroyWindow(ToolWindow);
		ImageList_Destroy(hImgListTool);
		internal_close(0);
		break;

	default:
		return false;
	}

	return true;
}
Exemplo n.º 11
0
LRESULT
PerfOnInitDialog(
	IN HWND hWnd,
	IN UINT uMsg,
	IN WPARAM wp,
	IN LPARAM lp
	)
{
	RECT Rect;
	HWND hWndCtrl;
	PGRAPH_CONTROL Graph;
	PDIALOG_OBJECT Object;
	HWND hWndDesktop;
	PPERF_DIALOG_CONTEXT Context;
	LVCOLUMN Column = {0};
	WCHAR Buffer[MAX_PATH];

	Object = (PDIALOG_OBJECT)SdkGetObject(hWnd);
	Context = SdkGetContext(Object, PERF_DIALOG_CONTEXT);

	hWndDesktop = GetDesktopWindow();

	hWndCtrl = GetDlgItem(hWnd, IDC_STATIC_CPU);
	GetWindowRect(hWndCtrl, &Rect);
	MapWindowRect(hWndDesktop, hWnd, &Rect);

	//
	// CPU graph
	//

	Graph = GraphCreateControl(hWnd, IDC_STATIC_CPU, &Rect,
		                       RGB(212, 208, 200), RGB(130, 130, 130), 
							   RGB(255, 128, 128), RGB(255, 0, 0));

	Graph->HistoryCallback = PerfGraphHistoryCallback;
	Graph->HistoryContext = Object;
	Context->Graph[PerfGraphCpu] = Graph;

	hWndCtrl = GetDlgItem(hWnd, IDC_STATIC_MEMORY);
	GetWindowRect(hWndCtrl, &Rect);
	MapWindowRect(hWndDesktop, hWnd, &Rect);

	//
	// Memory Graph
	//

	Graph = GraphCreateControl(hWnd, IDC_STATIC_MEMORY, &Rect,
                		       RGB(212, 208, 200), RGB(130, 130, 130), 
							   RGB(158, 202, 158), RGB(60, 148, 60));

	Graph->HistoryCallback = PerfGraphHistoryCallback;
	Graph->HistoryContext = Object;
	Context->Graph[PerfGraphMemory] = Graph;

	hWndCtrl = GetDlgItem(hWnd, IDC_STATIC_IO);
	GetWindowRect(hWndCtrl, &Rect);
	MapWindowRect(hWndDesktop, hWnd, &Rect);

	//
	// I/O Graph
	//

	Graph = GraphCreateControl(hWnd, IDC_STATIC_IO, &Rect,
		                	   RGB(212, 208, 200), RGB(130, 130, 130), 
							   RGB(144, 158, 228), RGB(30, 60, 200));
							   
	Graph->HistoryCallback = PerfGraphHistoryCallback;
	Graph->HistoryContext = Object;
	Context->Graph[PerfGraphIo] = Graph;

	hWndCtrl = GetDlgItem(hWnd, IDC_STATIC_CAPTION);
	SetWindowText(hWndCtrl, L"Performance Counter Report:");

	PerfInsertTaskList(Object, hWnd);
	PerfInsertCounterList(Object, hWnd);
	PerfRegisterCallback(PerfGraphConsumerCallback, (PVOID)Object);

	//
	// Set default task pane
	//

	LoadString(SdkInstance, IDS_PERFMON, Buffer, MAX_PATH);
	SetWindowText(hWnd, Buffer);

	hWndCtrl = GetDlgItem(hWnd, IDC_LIST_PERF_PROCESS);
	SetFocus(hWndCtrl);
	ListView_SetItemState(hWndCtrl, 0, LVIS_SELECTED, LVIS_SELECTED);

	SdkSetMainIcon(hWnd);
	SdkCenterWindow(hWnd);

	PerfStartWorkItem();
	return 0;
}
Exemplo n.º 12
0
INT_PTR CControllerManager::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		{
			const size_t NumControllers=m_ControllerList.size();
			if (NumControllers>0) {
				m_CurSettingsList.resize(NumControllers);
				int Sel=0;
				for (size_t i=0;i<NumControllers;i++) {
					const ControllerInfo &Info=m_ControllerList[i];

					DlgComboBox_AddString(hDlg,IDC_CONTROLLER_LIST,Info.pController->GetText());
					if (!m_CurController.empty()
							&& ::lstrcmpi(m_CurController.c_str(),Info.pController->GetName())==0)
						Sel=(int)i;
					m_CurSettingsList[i]=Info.Settings;
				}
				DlgComboBox_SetCurSel(hDlg,IDC_CONTROLLER_LIST,Sel);
			}
			EnableDlgItem(hDlg,IDC_CONTROLLER_LIST,NumControllers>0);

			HWND hwndList=::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN);
			ListView_SetExtendedListViewStyle(hwndList,
				LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP);
			LV_COLUMN lvc;
			lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
			lvc.fmt=LVCFMT_LEFT;
			lvc.cx=120;
			lvc.pszText=TEXT("ボタン");
			ListView_InsertColumn(hwndList,0,&lvc);
			lvc.pszText=TEXT("コマンド");
			ListView_InsertColumn(hwndList,1,&lvc);

			const CCommandList &CommandList=GetAppClass().CommandList;
			TCHAR szText[CCommandList::MAX_COMMAND_NAME];
			DlgComboBox_AddString(hDlg,IDC_CONTROLLER_COMMAND,TEXT("なし"));
			for (int i=0;i<CommandList.NumCommands();i++) {
				CommandList.GetCommandName(i,szText,lengthof(szText));
				DlgComboBox_AddString(hDlg,IDC_CONTROLLER_COMMAND,szText);
			}

			m_Tooltip.Create(hDlg);
			m_Tooltip.SetFont(GetWindowFont(hDlg));

			InitDlgItems();
			SetDlgItemStatus();
		}
		return TRUE;

	case WM_PAINT:
		{
			if (m_hbmController==NULL)
				break;

			const CController *pController=GetCurController();
			if (pController==NULL)
				break;

			int CurButton=ListView_GetNextItem(::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN),-1,LVNI_SELECTED);

			PAINTSTRUCT ps;
			BITMAP bm;
			RECT rc;
			HDC hdcMem;
			HBITMAP hbmOld;

			::BeginPaint(hDlg,&ps);
			::GetObject(m_hbmController,sizeof(BITMAP),&bm);
			::GetWindowRect(::GetDlgItem(hDlg,IDC_CONTROLLER_IMAGEPLACE),&rc);
			MapWindowRect(NULL,hDlg,&rc);
			::FillRect(ps.hdc,&rc,static_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH)));
			hdcMem=::CreateCompatibleDC(ps.hdc);
			hbmOld=static_cast<HBITMAP>(::SelectObject(hdcMem,m_hbmController));
			::BitBlt(ps.hdc,m_ImageRect.left,m_ImageRect.top,
							bm.bmWidth,bm.bmHeight,hdcMem,0,0,SRCCOPY);
			if (CurButton>=0 && m_hbmSelButtons!=NULL) {
				CController::ButtonInfo Button;

				pController->GetButtonInfo(CurButton,&Button);
				::SelectObject(hdcMem,m_hbmSelButtons);
				::GdiTransparentBlt(ps.hdc,
					m_ImageRect.left+Button.ImageButtonRect.Left,
					m_ImageRect.top+Button.ImageButtonRect.Top,
					Button.ImageButtonRect.Width,
					Button.ImageButtonRect.Height,
					hdcMem,
					Button.ImageSelButtonPos.Left,
					Button.ImageSelButtonPos.Top,
					Button.ImageButtonRect.Width,
					Button.ImageButtonRect.Height,
					RGB(255,0,255));
			}
			::SelectObject(hdcMem,hbmOld);
			::DeleteDC(hdcMem);
			::EndPaint(hDlg,&ps);
		}
		return TRUE;

	case WM_LBUTTONDOWN:
		{
			POINT pt;

			pt.x=GET_X_LPARAM(lParam);
			pt.y=GET_Y_LPARAM(lParam);
			if (m_hbmSelButtons!=NULL
					&& ::PtInRect(&m_ImageRect,pt)) {
				const CController *pController=GetCurController();
				if (pController==NULL)
					return TRUE;

				const int NumButtons=pController->NumButtons();
				for (int i=0;i<NumButtons;i++) {
					CController::ButtonInfo Button;
					RECT rc;

					pController->GetButtonInfo(i,&Button);
					rc.left=m_ImageRect.left+Button.ImageButtonRect.Left;
					rc.top=m_ImageRect.top+Button.ImageButtonRect.Top;
					rc.right=rc.left+Button.ImageButtonRect.Width;
					rc.bottom=rc.top+Button.ImageButtonRect.Height;
					if (::PtInRect(&rc,pt)) {
						HWND hwndList=::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN);

						ListView_SetItemState(hwndList,i,
											  LVIS_FOCUSED | LVIS_SELECTED,
											  LVIS_FOCUSED | LVIS_SELECTED);
						ListView_EnsureVisible(hwndList,i,FALSE);
						::SetFocus(hwndList);
						break;
					}
				}
			}
		}
		return TRUE;

	case WM_SETCURSOR:
		if (LOWORD(lParam)==HTCLIENT) {
			if (m_hbmSelButtons!=NULL) {
				POINT pt;

				::GetCursorPos(&pt);
				::ScreenToClient(hDlg,&pt);
				if (::PtInRect(&m_ImageRect,pt)) {
					const CController *pController=GetCurController();
					if (pController==NULL)
						break;

					const int NumButtons=pController->NumButtons();
					for (int i=0;i<NumButtons;i++) {
						CController::ButtonInfo Button;
						RECT rc;

						pController->GetButtonInfo(i,&Button);
						rc.left=m_ImageRect.left+Button.ImageButtonRect.Left;
						rc.top=m_ImageRect.top+Button.ImageButtonRect.Top;
						rc.right=rc.left+Button.ImageButtonRect.Width;
						rc.bottom=rc.top+Button.ImageButtonRect.Height;
						if (::PtInRect(&rc,pt)) {
							::SetCursor(::LoadCursor(NULL,IDC_HAND));
							::SetWindowLongPtr(hDlg,DWLP_MSGRESULT,TRUE);
							return TRUE;
						}
					}
				}
			}
		}
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CONTROLLER_LIST:
			if (HIWORD(wParam)==CBN_SELCHANGE) {
				const CController *pCurController=GetCurController();

				InitDlgItems();
				if (pCurController!=NULL) {
					m_CurController=pCurController->GetName();
					m_fChanged=true;
				}
			}
			return TRUE;

		case IDC_CONTROLLER_ACTIVEONLY:
			{
				int CurController=(int)DlgComboBox_GetCurSel(hDlg,IDC_CONTROLLER_LIST);

				if (CurController>=0) {
					m_CurSettingsList[CurController].fActiveOnly=
						DlgCheckBox_IsChecked(hDlg,IDC_CONTROLLER_ACTIVEONLY);
				}
			}
			return TRUE;

		case IDC_CONTROLLER_COMMAND:
			if (HIWORD(wParam)==CBN_SELCHANGE) {
				HWND hwndList=::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN);
				int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

				if (Sel>=0) {
					int Command=(int)DlgComboBox_GetCurSel(hDlg,IDC_CONTROLLER_COMMAND);

					SetButtonCommand(hwndList,Sel,
						Command<=0?0:GetAppClass().CommandList.GetCommandID(Command-1));
				}
			}
			return TRUE;

		case IDC_CONTROLLER_DEFAULT:
			{
				const CController *pController=GetCurController();
				if (pController==NULL)
					return TRUE;

				HWND hwndList=::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN);
				const int NumButtons=pController->NumButtons();
				for (int i=0;i<NumButtons;i++) {
					CController::ButtonInfo Button;

					pController->GetButtonInfo(i,&Button);
					SetButtonCommand(hwndList,i,Button.DefaultCommand);
				}
				SetDlgItemStatus();
			}
			return TRUE;
		}
		return TRUE;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code) {
		case LVN_ITEMCHANGED:
			SetDlgItemStatus();
			::InvalidateRect(hDlg,&m_ImageRect,FALSE);
			break;

		case LVN_KEYDOWN:
			{
				LPNMLVKEYDOWN pnmlvk=reinterpret_cast<LPNMLVKEYDOWN>(lParam);

				if (pnmlvk->wVKey==VK_BACK || pnmlvk->wVKey==VK_DELETE) {
					HWND hwndList=::GetDlgItem(hDlg,IDC_CONTROLLER_ASSIGN);
					int Sel=ListView_GetNextItem(hwndList,-1,LVNI_SELECTED);

					if (Sel>=0)
						SetButtonCommand(hwndList,Sel,0);
				}
			}
			break;

		case PSN_APPLY:
			{
				for (size_t i=0;i<m_ControllerList.size();i++) {
					ControllerInfo &Info=m_ControllerList[i];
					ControllerSettings &CurSettings=m_CurSettingsList[i];

					if (Info.Settings!=CurSettings) {
						if (Info.pController->IsEnabled()) {
							if (CurSettings.fActiveOnly!=Info.Settings.fActiveOnly) {
								Info.pController->Enable(false);
								Info.Settings.fActiveOnly=CurSettings.fActiveOnly;
								Info.pController->Enable(true);
							}
						}
						Info.Settings=CurSettings;
						Info.fSettingsChanged=true;
					}
				}
			}
			break;
		}
		break;

	case WM_DESTROY:
		{
			if (m_hbmController!=NULL) {
				::DeleteObject(m_hbmController);
				m_hbmController=NULL;
			}
			if (m_hbmSelButtons!=NULL) {
				::DeleteObject(m_hbmSelButtons);
				m_hbmSelButtons=NULL;
			}
			m_CurSettingsList.clear();
			m_Tooltip.Destroy();
		}
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 13
0
void CControllerManager::InitDlgItems()
{
	HWND hwndList=::GetDlgItem(m_hDlg,IDC_CONTROLLER_ASSIGN);
	ListView_DeleteAllItems(hwndList);

	if (m_hbmController!=NULL) {
		::DeleteObject(m_hbmController);
		m_hbmController=NULL;
	}
	if (m_hbmSelButtons!=NULL) {
		::DeleteObject(m_hbmSelButtons);
		m_hbmSelButtons=NULL;
	}
	m_Tooltip.DeleteAllTools();

	int Sel=(int)DlgComboBox_GetCurSel(m_hDlg,IDC_CONTROLLER_LIST);
	if (Sel>=0) {
		const CCommandList &CommandList=GetAppClass().CommandList;
		const ControllerInfo &Info=m_ControllerList[Sel];
		const CController *pController=Info.pController;
		const int NumButtons=pController->NumButtons();

		if (!Info.fSettingsLoaded) {
			if (LoadControllerSettings(pController->GetName()))
				m_CurSettingsList[Sel]=Info.Settings;
		}

		bool fActiveOnly=pController->IsActiveOnly();
		EnableDlgItem(m_hDlg,IDC_CONTROLLER_ACTIVEONLY,!fActiveOnly);
		DlgCheckBox_Check(m_hDlg,IDC_CONTROLLER_ACTIVEONLY,
						  fActiveOnly || m_CurSettingsList[Sel].fActiveOnly);

		for (int i=0;i<NumButtons;i++) {
			CController::ButtonInfo Button;
			int Command=m_CurSettingsList[Sel].AssignList[i];
			LV_ITEM lvi;

			pController->GetButtonInfo(i,&Button);
			lvi.mask=LVIF_TEXT | LVIF_PARAM;
			lvi.iItem=i;
			lvi.iSubItem=0;
			lvi.pszText=const_cast<LPTSTR>(Button.pszName);
			lvi.lParam=Command;
			lvi.iItem=ListView_InsertItem(hwndList,&lvi);
			if (Command>0) {
				TCHAR szText[CCommandList::MAX_COMMAND_NAME];

				lvi.mask=LVIF_TEXT;
				lvi.iSubItem=1;
				CommandList.GetCommandNameByID(Command,szText,lengthof(szText));
				lvi.pszText=szText;
				ListView_SetItem(hwndList,&lvi);
			}
		}
		for (int i=0;i<2;i++)
			ListView_SetColumnWidth(hwndList,i,LVSCW_AUTOSIZE_USEHEADER);

		m_hbmController=pController->GetImage(CController::IMAGE_CONTROLLER);
		if (m_hbmController!=NULL) {
			RECT rc;

			BITMAP bm;
			::GetObject(m_hbmController,sizeof(BITMAP),&bm);
			::GetWindowRect(::GetDlgItem(m_hDlg,IDC_CONTROLLER_IMAGEPLACE),&rc);
			MapWindowRect(NULL,m_hDlg,&rc);
			m_ImageRect.left=rc.left+((rc.right-rc.left)-bm.bmWidth)/2;
			m_ImageRect.top=rc.top+((rc.bottom-rc.top)-bm.bmHeight)/2;
			m_ImageRect.right=m_ImageRect.left+bm.bmWidth;
			m_ImageRect.bottom=m_ImageRect.top+bm.bmHeight;

			m_hbmSelButtons=pController->GetImage(CController::IMAGE_SELBUTTONS);

			if (m_hbmSelButtons!=NULL) {
				for (int i=0;i<NumButtons;i++) {
					CController::ButtonInfo Button;

					pController->GetButtonInfo(i,&Button);
					rc.left=m_ImageRect.left+Button.ImageButtonRect.Left;
					rc.top=m_ImageRect.top+Button.ImageButtonRect.Top;
					rc.right=rc.left+Button.ImageButtonRect.Width;
					rc.bottom=rc.top+Button.ImageButtonRect.Height;
					m_Tooltip.AddTool(i,rc,const_cast<LPTSTR>(Button.pszName));
				}
			}
		}
	}
	EnableDlgItems(m_hDlg,IDC_CONTROLLER_ACTIVEONLY,IDC_CONTROLLER_DEFAULT,Sel>=0);
	DlgComboBox_SetCurSel(m_hDlg,IDC_CONTROLLER_COMMAND,0);
	EnableDlgItem(m_hDlg,IDC_CONTROLLER_COMMAND,false);
	::InvalidateRect(m_hDlg,NULL,TRUE);
}
//Load Dialog box
INT_PTR WINAPI DlgLoadProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	static unsigned8* result;

	switch  (wMsg) 
	{
		case WM_INITDIALOG:
			{
				if (lParam)
				{
					result = reinterpret_cast<unsigned8*>(lParam);

					//If no mip maps hide controls
					if (!(*result & LoadInfoEnum::USE_MIPMAPS))
					{
						ShowWindow(GetDlgItem(hDlg, IDC_LOADDIALOG_MIPMAPGROUP), SW_HIDE);
						ShowWindow(GetDlgItem(hDlg, IDC_LOADDIALOG_MIPMAPCHECK), SW_HIDE);
					}

					//If no alpha hide controls
					if (!(*result & LoadInfoEnum::USE_SEPARATEALPHA))
					{
						ShowWindow(GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHAGROUP), SW_HIDE);
						ShowWindow(GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHACHECK), SW_HIDE);

						//move mipmap controls up
						RECT rcGroup = {};
						RECT rcCheckbox = {};
						HWND group = GetDlgItem(hDlg, IDC_LOADDIALOG_MIPMAPGROUP);
						HWND checkbox = GetDlgItem(hDlg, IDC_LOADDIALOG_MIPMAPCHECK);
						
						//Get alpha rectangles in client coordinates and set them to mip map controls
                    	GetWindowRect(GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHAGROUP), &rcGroup);
						MapWindowRect(NULL, hDlg, &rcGroup);
						MoveWindow(group, rcGroup.left, rcGroup.top, rcGroup.right - rcGroup.left, rcGroup.bottom - rcGroup.top, TRUE);
						
						GetWindowRect(GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHACHECK), &rcCheckbox);
						MapWindowRect(NULL, hDlg, &rcCheckbox);
						MoveWindow(checkbox, rcCheckbox.left, rcCheckbox.top, rcCheckbox.right - rcCheckbox.left, rcCheckbox.bottom - rcCheckbox.top, TRUE);
					}

					//Reset result to pass back info
					*result = LoadInfoEnum::USE_NONE;
				}
                CenterDialog(hDlg);	
			}
            break;

		case WM_COMMAND:
			switch  (COMMANDID(wParam)) 
			{
				case IDOK:
					{
						EndDialog(hDlg, IDOK);
					}
                    break;

				case IDCANCEL:
					{
						*result = LoadInfoEnum::USE_NONE;
						EndDialog(hDlg, IDCANCEL);
					}
					break;
				case IDC_LOADDIALOG_MIPMAPCHECK:
					{
						HWND alphachkbox = GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHACHECK);
						bool checked = (SendMessage(GetDlgItem(hDlg, IDC_LOADDIALOG_MIPMAPCHECK), BM_GETCHECK, 0, 0) == BST_CHECKED);
						
						//Set the flag depending on the checked state
						if (checked) 
						{
						    *result |= LoadInfoEnum::USE_MIPMAPS;

							//uncheck and disable separate alpha setting on mip maps;
							if (GetWindowLong(alphachkbox, GWL_STYLE) | WS_VISIBLE)
							{
								SendMessage(alphachkbox, BM_SETCHECK, 0, 0);
								::EnableWindow(alphachkbox, false);
							}
						}
						else
						{
						    *result &= ~LoadInfoEnum::USE_MIPMAPS;

							//reenable alpha checkbox
							if (GetWindowLong(alphachkbox, GWL_STYLE) | WS_VISIBLE)
							{
								::EnableWindow(alphachkbox, true);
							}
						}
					}
					break;
				case IDC_LOADDIALOG_ALPHACHECK:
					{
						bool checked = (SendMessage(GetDlgItem(hDlg, IDC_LOADDIALOG_ALPHACHECK), BM_GETCHECK, 0, 0) == BST_CHECKED);
						
						//set the flag depending on the checked state
						if (checked) 
						    *result |= LoadInfoEnum::USE_SEPARATEALPHA;
						else
						    *result &= ~LoadInfoEnum::USE_SEPARATEALPHA;
					}
					break;

				default:
                    return FALSE;
            }
            break;

	  case WM_CTLCOLORSTATIC: 
		  { 
			//set the background color of the chackbox controls
			 static HBRUSH hBrushColor; 
		     if (!hBrushColor) 
			 { 
				 hBrushColor = CreateSolidBrush(RGB(255, 255, 255)); 
				 SetBkColor((HDC)wParam, RGB(255, 255, 255)); 
			 } 
			 return (LRESULT)hBrushColor; 
		  }
		  break;

	  case WM_PAINT:
		   {
				PAINTSTRUCT ps;
				HDC hDC;
				hDC = BeginPaint(hDlg, &ps);	
				RECT rcParent = {5, 5, 295, 115};

				//Paint the white rectabgle where the checkboxes are positioned
				FillRect(hDC, &rcParent, static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
				EndPaint(hDlg, &ps);
				return FALSE;
			}
		  break;

      default:
		  return  FALSE;
	
	} // switch (wMsg)

    return  TRUE;
}
Exemplo n.º 15
0
/**
 * Custom handling for WM_NCHITTEST
 * We paint the sizing grip if the mouse is in the lower right hand corner.
 */
bool
CMoveConstraint::OnNcHitTest(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT * plresult)
{
	// views don't get WM_NCHITTEST, but dialogs & frames do
	if (!m_hwndDlg)
		return false;
	if (m_nMinY == m_nMaxY)
	{
		LRESULT nRet = CallWindowProc(m_oldWndProc, m_hwndDlg, msg, wParam, lParam);
		switch(nRet)
		{
		case HTBOTTOMLEFT:
		case HTTOPLEFT:
			*plresult = HTLEFT;
			return true;
		case HTBOTTOMRIGHT:
		case HTTOPRIGHT:
			*plresult = HTRIGHT;
			return true;
		case HTBOTTOM:
		case HTTOP:
			*plresult = HTBORDER;
			return true;
		}
		return false;
	}
	if (m_nMinX == m_nMaxX)
	{
		LRESULT nRet = CallWindowProc(m_oldWndProc, m_hwndDlg, msg, wParam, lParam);
		switch(nRet)
		{
		case HTBOTTOMLEFT:
		case HTBOTTOMRIGHT:
			*plresult = HTBOTTOM;
			return true;
		case HTTOPLEFT:
		case HTTOPRIGHT:
			*plresult = HTTOP;
			return true;
		case HTLEFT:
		case HTRIGHT:
			*plresult = HTBORDER;
			return true;
		}
		return false;
	}
	if (!PaintGrip())
		return false;

	// check for size grip
	int x = (int)(short)LOWORD(lParam);
	int y = (int)(short)HIWORD(lParam);
	int cx,cy;
	RECT rc = getGripRect(m_hwndDlg);
	MapWindowRect(m_hwndDlg, HWND_DESKTOP, &rc);
	RECT rc2;
	GetWindowRect(m_hwndDlg, &rc2);
	cx = x-rc.left;
	cy = y-rc.top;
	if (0 < cx && 0 < cy && (rc.right - rc.left < cy+cy))
	{
		*plresult = HTBOTTOMRIGHT;
		return true;
	}
	return false;
}