Example #1
0
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND hwndList,hwndboton,hwndlabel1,hwndlabel2,hwndtext,hwndboton2;
    int iIndex, iLength, cxChar, cyChar;
    char nombre[260];
    char numero[30];

	switch (message)                 
    {
    	case WM_CTLCOLORSTATIC:
		{   
            HDC hdcStatic = (HDC) wParam;

            SetBkColor(hdcStatic,RGB(211,208,201));
            return (INT_PTR)CreateSolidBrush(RGB(211,208,201));
		}
	    case WM_CREATE:
		{
            cxChar = LOWORD(GetDialogBaseUnits());
            cyChar = HIWORD(GetDialogBaseUnits());

			hwndlabel1 = CreateWindowEx(0,"static", "Selecciona el proceso a Dumpear:", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 10, 10, 230, 20, hwnd, 0, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
			hwndlabel2 = CreateWindowEx(0,"static", "Número de offsets a dumpear:", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 10, 60, 230, 20, hwnd, 0, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
			hwndList =  CreateWindow(TEXT("Combobox"), NULL, WS_CHILD | WS_VISIBLE |LBS_STANDARD, 10, 30, 200,60, hwnd, (HMENU)ID_LIST, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE),NULL);
            hwndboton = CreateWindowEx(0,"BUTTON", "Refrescar", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 215, 30, 70, 20, hwnd, 0, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
			hwndtext = CreateWindowEx(0,"Edit", "", WS_CHILD|WS_VISIBLE|WS_BORDER, 215, 60, 70, 20, hwnd, 0, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
			hwndboton2 = CreateWindowEx(0,"BUTTON", "Dumpear!", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 10, 85, 275, 20, hwnd, 0, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
			
			Opciones(hwndList);
             
            return 0;
		}  
        case WM_COMMAND:
		{
			 if((HWND)lParam==hwndboton)
			 {
                 Opciones(hwndList);
				 MessageBoxA(miid,"Se a refrescado la lista de procesos","Drink Dump v1.0",MB_OK);
			 }
             if((HWND)lParam==hwndboton2)
			 {
                 GetWindowText(hwndtext,numero,10);
				 GetWindowText(hwndList,nombre,260);
                 Dumpear(nombre,numero);
			 }

             break;
		}
        case WM_DESTROY:
		{
			PostQuitMessage (0);       
            break;
		}
        default:                    
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
 
    return 0;
}
Example #2
0
File: cns.c Project: Akasurde/krb5
/*
 * Function: Process WM_GETMINMAXINFO messages
 */
static void
kwin_getminmaxinfo(HWND hwnd, LPMINMAXINFO lpmmi)
{
  lpmmi->ptMinTrackSize.x =
    (KWIN_MIN_WIDTH * LOWORD(GetDialogBaseUnits())) / 4;

  lpmmi->ptMinTrackSize.y =
    (KWIN_MIN_HEIGHT * HIWORD(GetDialogBaseUnits())) / 8;
}
Example #3
0
HBITMAP StretchBitmap (HBITMAP hBitmap1)
{
     BITMAP     bm1, bm2 ;
     HBITMAP    hBitmap2 ;
     HDC        hdc, hdcMem1, hdcMem2 ;
     int        cxChar, cyChar ;

          // Get the width and height of a system font character

     cxChar = LOWORD (GetDialogBaseUnits ()) ;
     cyChar = HIWORD (GetDialogBaseUnits ()) ;

          // Create 2 memory DCs compatible with the display
     
     hdc = CreateIC (TEXT ("DISPLAY"), NULL, NULL, NULL) ;
     hdcMem1 = CreateCompatibleDC (hdc) ;
     hdcMem2 = CreateCompatibleDC (hdc) ;
     DeleteDC (hdc) ;

          // Get the dimensions of the bitmap to be stretched
     
     GetObject (hBitmap1, sizeof (BITMAP), (PTSTR) &bm1) ;

          // Scale these dimensions based on the system font size
     
     bm2 = bm1 ;
     bm2.bmWidth      = (cxChar * bm2.bmWidth)  / 4 ;
     bm2.bmHeight     = (cyChar * bm2.bmHeight) / 8 ;
     bm2.bmWidthBytes = ((bm2.bmWidth + 15) / 16) * 2 ;

          // Create a new bitmap of larger size
     
     hBitmap2 = CreateBitmapIndirect (&bm2) ;

          // Select the bitmaps in the memory DCs and do a StretchBlt
     
     SelectObject (hdcMem1, hBitmap1) ;
     SelectObject (hdcMem2, hBitmap2) ;
     
     StretchBlt (hdcMem2, 0, 0, bm2.bmWidth, bm2.bmHeight,
                 hdcMem1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY) ;

          // Clean up
     
     DeleteDC (hdcMem1) ;
     DeleteDC (hdcMem2) ;
     DeleteObject (hBitmap1) ;
     
     return hBitmap2 ;
}
Example #4
0
File: ui.c Project: DeltaYang/wine
static int create_item(HDC hdc, const SANE_Option_Descriptor *opt,
        INT id, LPDLGITEMTEMPLATEW *template_out, int y, int *cx, int* count)
{
    LPDLGITEMTEMPLATEW tpl = NULL,rc = NULL;
    WORD class = 0xffff;
    DWORD styles = WS_VISIBLE;
    LPBYTE ptr = NULL;
    LPDLGITEMTEMPLATEW lead_static = NULL;
    LPDLGITEMTEMPLATEW trail_edit = NULL;
    DWORD leading_len = 0;
    DWORD trail_len = 0;
    DWORD local_len = 0;
    LPCSTR title = NULL;
    CHAR buffer[255];
    int padding = 0;
    int padding2 = 0;
    int base_x = 0;
    LONG base;
    int ctl_cx = 0;
    SIZE size;

    GetTextExtentPoint32A(hdc,"X",1,&size);
    base = GetDialogBaseUnits();
    base_x = MulDiv(size.cx,4,LOWORD(base));

    if (opt->type == SANE_TYPE_BOOL)
    {
        class = 0x0080; /* Button */
        styles |= BS_AUTOCHECKBOX;
        local_len += MultiByteToWideChar(CP_ACP,0,opt->title,-1,NULL,0);
        local_len *= sizeof(WCHAR);
        title = opt->title;
    }
    else if (opt->type == SANE_TYPE_INT)
Example #5
0
void CPrefView::ReSize()
{
	CRect rect;
	CRect rect_cy;
	GetClientRect(rect);
	int x=rect.right;
	int y=rect.bottom;
//	if (x<500) x=500;
//	if (y<400) y=400;
	LONG l=GetDialogBaseUnits();
	double kx=LOWORD(l)/8.0;
	double ky=HIWORD(l)/16.0;

	m_ComboY.GetClientRect(rect_cy);
	WORD dx=6;
	WORD dy=13;
	int x1,y1;
	x1=(136*dx)/4; y1=(125*dy)/8;
	//m_Grid.MoveWindow((int)(x1*kx),(int)(y1*ky),(int)(x-x1*kx-10),(int)(y-y1*ky-10));
	m_Grid.MoveWindow(rect_cy.right+30,(int)(y1*ky),(int)(x-rect_cy.right-40),(int)(y-y1*ky-10));
	GetDlgItem(IDC_STATIC_FACE)->MoveWindow((int)(x-40*kx),(int)(33*ky),32,32);
	x1=(140*dx)/4; y1=(13*dy)/8;
	//GetDlgItem(IDC_STATIC_SCALE)->MoveWindow((int)(x1*kx),(int)(33*ky),(int)(x-(x1+50)*kx),(int)(20*ky));
	GetDlgItem(IDC_STATIC_SCALE)->MoveWindow(rect_cy.right+30,(int)(33*ky),(int)(x-rect_cy.right-30-50*kx),(int)(20*ky));
	//y1=(25*dy)/8;
	//m_Slider.MoveWindow((int)(x1*kx),(int)(55*ky),(int)(x-(x1+50)*kx),(int)(30*ky));
	m_Slider.MoveWindow(rect_cy.right+30,(int)(55*ky),(int)(x-rect_cy.right-30-50*kx),(int)(30*ky));
}
Example #6
0
static void hugsprim_GetDialogBaseUnits_10(HugsStackPtr hugs_root)
{
    HsInt32 res1;
    res1 = GetDialogBaseUnits();
    hugs->putInt32(res1);
    hugs->returnIO(hugs_root,1);
}
Example #7
0
static void PASCAL CenterWindowOnCursor(HWND hWnd)
{
  POINT pt;
  RECT  rcWin;
  int   cxScreen=GetSystemMetrics(SM_CXSCREEN);
  int   cyScreen=GetSystemMetrics(SM_CYSCREEN);
  int   x,y;

  GetWindowRect(hWnd,&rcWin);
  OffsetRect   (&rcWin,-rcWin.left,-rcWin.top);

  GetCursorPos(&pt);
  x=pt.x-(rcWin.right/2);
  y=pt.y-(GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION)+HIWORD(GetDialogBaseUnits()));

  if (x<0)
    x=0;
  else if (x+rcWin.right>cxScreen)
    x=cxScreen-rcWin.right;

  if (y<0)
    y=0;
  else if (y+rcWin.bottom>cyScreen)
    y=cyScreen-rcWin.bottom;

  MoveWindow(hWnd,x,y,rcWin.right,rcWin.bottom,FALSE);
}
Example #8
0
DWORD far pascal zGetDialogBaseUnits()
{
    DWORD r;

    SaveRegs();
    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:GetDialogBaseUnits " );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = GetDialogBaseUnits();
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:GetDialogBaseUnits DWORD+", r );

    RestoreRegs();
    return( r );
}
Example #9
0
void    WINAPI
MapDialogRect(HWND hDlg, RECT FAR *lpRect)
{
    HDC hDC;
    HFONT hFont, hFontOld = 0;
    TEXTMETRIC TextMetrics;
    DWORD dwFontUnits;
    int width, height;

    hDC = GetDC(hDlg);
    hFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
    if ( hFont )
        hFontOld = SelectObject(hDC, hFont);

    if ( GetTextMetrics(hDC, &TextMetrics) ) {
        width  = TextMetrics.tmAveCharWidth;
        height = TextMetrics.tmHeight;
    } else {
        dwFontUnits = GetDialogBaseUnits();
        width  = (int)LOWORD(dwFontUnits);
        height = (int)HIWORD(dwFontUnits);
    }

    if ( hFontOld )
        SelectObject(hDC, hFontOld);
    ReleaseDC(hDlg,hDC);

    lpRect->left    = MulDiv(lpRect->left,   width,  4);
    lpRect->top     = MulDiv(lpRect->top,    height, 8);
    lpRect->right   = MulDiv(lpRect->right,  width,  4);
    lpRect->bottom  = MulDiv(lpRect->bottom, height, 8);
}
Example #10
0
/*-----------------------------------------------------------------------------
FUNCTION: GlobalInitialize

PURPOSE: Intializes global variables before any windows are created

COMMENTS: Partner to GlobalCleanup

HISTORY:   Date:      Author:     Comment:
           10/27/95   AllenD      Wrote it

-----------------------------------------------------------------------------*/
void GlobalInitialize()
{
#if USEWIN32

    int cyMenuHeight, cyCaptionHeight, cyFrameHeight;
    int k;


    //
    // font for status reporting control
    //
    ghFontStatus = CreateStatusEditFont();
    ghFontVTTY = CreateVTTYFont();

    //
    // the following are used for sizing the tty window and dialog windows
    //
    gwBaseY = HIWORD(GetDialogBaseUnits());
    cyMenuHeight = GetSystemMetrics(SM_CYMENU);
    cyCaptionHeight = GetSystemMetrics(SM_CYCAPTION);
    cyFrameHeight = GetSystemMetrics(SM_CYFRAME);
    gcyMinimumWindowHeight = cyMenuHeight + \
                            4 * cyCaptionHeight + \
                            2 * cyFrameHeight +
                            (SETTINGSFACTOR + STATUSFACTOR) * gwBaseY ;
#endif
    return ;
}
Example #11
0
static HFONT GetNewBrowserFont(HDC hDC, LPSTR pTypeFace,
                               WORD wStyle, int size,
                               BYTE bItalic, BYTE bUnderline, BYTE bVector)
{
    if (!FontFace[0])
    {
        WORD ylu = HIWORD(GetDialogBaseUnits());
        
        KppGetKappaIniFile(return_buffer, RET_BUFFER_LEN);
        GetPrivateProfileString("Browser", "FontFace", "Default", 
                                FontFace, 32, return_buffer);
        FontSize = GetPrivateProfileInt("Browser", "FontSize",
                                        wStartFontSize, return_buffer);
        /* Get FontSize in points */
        FontSize = (FontSize * ylu * 72) / (8 * wLogPixelY);
        bDefaultFont = !strcmpi(FontFace, "Default");
    }
    
    if (bDefaultFont)
        strcpy(FontFace, pTypeFace);
    else if (size == (int) wStartFontSize)
        size = FontSize;
    
    if (wStartFontSize != START_FONT_SIZE)
        size = MulDiv(size, wStartFontSize, START_FONT_SIZE);
        
    return GetNewFont(FontFace, wStyle, size, bItalic, bUnderline, bVector);
}
Example #12
0
INT_PTR CALLBACK OptionsPageMore::aboutBoxDialogProc(
	HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_INITDIALOG)
	{
		int iconSize = LOWORD(GetDialogBaseUnits()) * 24 / 4;
		auto appIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_A),
			IMAGE_ICON, iconSize, iconSize, LR_DEFAULTCOLOR);
		Static_SetIcon(GetDlgItem(hwnd, IDC_ABOUT_ICON), appIcon);
		SetDlgItemText(hwnd, IDC_ABOUT_VERSION, L"Version: " APP_VERSION);
		SetDlgItemText(hwnd, IDC_ABOUT_DATE, L"Compiled on: " APP_DATE);
		return TRUE;
	}
	if (uMsg == WM_NOTIFY)
	{
		auto pHdr = (const PNMLINK) lParam;
		if (pHdr->hdr.code == NM_CLICK || pHdr->hdr.code == NM_RETURN)
		{
			ShellExecute(NULL, L"open", pHdr->item.szUrl, NULL, NULL, SW_SHOW);
			return TRUE;
		}
		else {
			return FALSE;
		}
	}
	else if (uMsg == WM_COMMAND && HIWORD(wParam) == BN_CLICKED)
	{
		DestroyIcon(Static_GetIcon(GetDlgItem(hwnd, IDC_ABOUT_ICON), 0));
		EndDialog(hwnd, IDOK);
		return TRUE;
	}
	else {
		return FALSE;
	}
}
Example #13
0
    static void
get_dialog_font_metrics(void)
{
    DWORD	    dlgFontSize;
	dlgFontSize = GetDialogBaseUnits();	/* fall back to big old system*/
	s_dlgfntwidth = LOWORD(dlgFontSize);
	s_dlgfntheight = HIWORD(dlgFontSize);
}
Example #14
0
/***********************************************************************
 *                    CC_PaintCross                           [internal]
 */
static void CC_PaintCross( HWND hDlg, int x, int y)
{
 HDC hDC;
 int w = GetDialogBaseUnits() - 1;
 int wc = GetDialogBaseUnits() * 3 / 4;
 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
 LPCCPRIV lpp = GetPropW( hDlg, szColourDialogProp );
 RECT rect;
 POINT point, p;
 HPEN hPen;

 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) ))   /* if full size */
 {
   GetClientRect(hwnd, &rect);
   hDC = GetDC(hwnd);
   SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));

   point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
   point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
   if ( lpp->oldcross.left != lpp->oldcross.right )
     BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top,
              lpp->oldcross.right - lpp->oldcross.left,
              lpp->oldcross.bottom - lpp->oldcross.top,
              lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY);
   lpp->oldcross.left   = point.x - w - 1;
   lpp->oldcross.right  = point.x + w + 1;
   lpp->oldcross.top    = point.y - w - 1;
   lpp->oldcross.bottom = point.y + w + 1;

   hPen = CreatePen(PS_SOLID, 3, 0x000000); /* -black- color */
   hPen = SelectObject(hDC, hPen);
   MoveToEx(hDC, point.x - w, point.y, &p);
   LineTo(hDC, point.x - wc, point.y);
   MoveToEx(hDC, point.x + wc, point.y, &p);
   LineTo(hDC, point.x + w, point.y);
   MoveToEx(hDC, point.x, point.y - w, &p);
   LineTo(hDC, point.x, point.y - wc);
   MoveToEx(hDC, point.x, point.y + wc, &p);
   LineTo(hDC, point.x, point.y + w);
   DeleteObject( SelectObject(hDC, hPen));

   ReleaseDC(hwnd, hDC);
 }
}
Example #15
0
void 
CAboutDialog::OnPaint(HDC hDC)
{
	//
	// HDC hDC is not a DC
	// bug in atlcrack.h
	//

	CPaintDC dc(m_hWnd);
	SIZE sizePic = {0, 0};
	m_pix.GetSizeInPixels(sizePic);

	CRect rcWnd, rcClient;
	GetClientRect(rcClient);
	GetWindowRect(rcWnd);

	ATLTRACE(_T("Picture Size: %d, %d\n"), sizePic.cx, sizePic.cy);
	ATLTRACE(_T("Client Size: %d, %d\n"), rcClient.Width(), rcClient.Height());
	ATLTRACE(_T("Window Size: %d, %d\n"), rcWnd.Width(), rcWnd.Height());

	//
	// adjust the picture size to the same width of the dialog
	//

	SIZE sizeAdj = 
	{ 
		rcWnd.Width(), 
		MulDiv(sizePic.cy, rcWnd.Width(), sizePic.cx)
	};

	LONG lBaseUnits = GetDialogBaseUnits();
	INT baseX = LOWORD(lBaseUnits);
	INT baseY = HIWORD(lBaseUnits);
	INT tplX = MulDiv(sizePic.cx, 4, baseX);
	INT tplY = MulDiv(sizePic.cy, 4, baseY);

	ATLTRACE(_T("Adjusted Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);

	//
	// avoid distortion from a little difference
	//
	int diff = sizePic.cx - sizeAdj.cx;
	diff = (diff > 0) ? diff : -diff;
	if (diff < 30)
	{
		sizeAdj = sizePic;
	}

	ATLTRACE(_T("Using Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);

	CRect rectPic(CPoint(0,0),sizeAdj);

	CDCHandle dcHandle;
	dcHandle.Attach((HDC)dc);
	m_pix.Render(dcHandle, rectPic);
}
LRESULT CALLBACK Main_WindowProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )       //主窗口窗口过程
{
	static HDC				Main_WindowHdc;
	static HINSTANCE		hInstance;
	static PAINTSTRUCT		ps;
	
	static HWND				Button_Handle[NUM];
	static int				cxChar, cyChar;

	switch( message )
	{
	case WM_CREATE:
		cxChar = LOWORD( GetDialogBaseUnits() );
		cyChar = HIWORD( GetDialogBaseUnits() );

		for( int i = 0; i < NUM; i++ )
		{
			Button_Handle[i] = CreateWindow ( TEXT( "Button" ),
											  button[i].szText,
											  WS_CHILD | WS_VISIBLE | button[i].iStyle,				//窗口风格
											  cxChar,												//窗口初始水平位置
											  cyChar * ( 1 + 2 * i ),								//窗口初始垂直位置
											  20 * cxChar,											//窗口宽
											  cyChar * 7 / 4,										//窗口高
											  hwnd,													//父窗口句柄
											  ( HMENU ) i,											//菜单句柄
											  hInstance,											//实例句柄
											  NULL );
		}
		return 0;

	case WM_PAINT:
		Main_WindowHdc = BeginPaint( hwnd, &ps );

		EndPaint( hwnd, &ps );
		return 0;

	case WM_DESTROY:
		PostQuitMessage( 0 );
		return 0;
	}
	return DefWindowProc( hwnd, message, wParam, lParam );
}
Example #17
0
ULONG FASTCALL WU32GetDialogBaseUnits(PVDMFRAME pFrame)
{
    ULONG ul;

    UNREFERENCED_PARAMETER(pFrame);

    ul = GETLONG16(GetDialogBaseUnits());

    RETURN(ul);
}
Example #18
0
HGLOBAL DLL_EXPORT decompress_block(void *data, DWORD datasize)
{
    HWND hwnd;
    MSG msg;
    WNDCLASS wndclass;
    RECT size;
    retData = (HGLOBAL) 0;

    int width = 50;
    int height = 50;
    int x,y;

    hwnd = GetDesktopWindow();
    GetWindowRect(hwnd,&size);
    width = LOWORD(GetDialogBaseUnits());
    height = HIWORD(GetDialogBaseUnits());
    width *= 50.5;
    height *= 27.5;

    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInstance;
    wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
    wndclass.lpszMenuName = NULL;
    wndclass.lpszClassName = "compress";
    RegisterClass(&wndclass);
    hwnd = CreateWindow("compress","Choose display mode", WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, ((size.right-size.left)/2)-(width/2), ((size.bottom-size.top)/2)-(height/2), width, height, NULL, NULL, hInstance, NULL);
    ShowWindow(hwnd, SW_SHOWNORMAL);
    UpdateWindow(hwnd);

    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return retData;
}
void plResponderProc::IDrawComboItem(DRAWITEMSTRUCT *dis)
{
    if (dis->itemID == -1)          // empty item
        return; 

    // The colors depend on whether the item is selected. 
    COLORREF clrForeground = SetTextColor(dis->hDC, 
        GetSysColor(dis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT)); 

    COLORREF clrBackground = SetBkColor(dis->hDC, 
        GetSysColor(dis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW)); 

    // Calculate the vertical and horizontal position.
    TEXTMETRIC tm;
    GetTextMetrics(dis->hDC, &tm);
    int y = (dis->rcItem.bottom + dis->rcItem.top - tm.tmHeight) / 2;
    int x = LOWORD(GetDialogBaseUnits()) / 4;

    // If this is a command, not a state, make it bold
    HFONT oldFont = nil;
    if (dis->itemData != kStateName)
    {
        LOGFONT lf;
        memset(&lf, 0, sizeof(lf));
        lf.lfHeight = tm.tmHeight;
        lf.lfWeight = FW_BOLD;
        GetTextFace(dis->hDC, LF_FACESIZE, lf.lfFaceName);
        HFONT boldFont = CreateFontIndirect(&lf);
        oldFont = SelectFont(dis->hDC, boldFont);
    }

    // Get and display the text for the list item.
    char buf[256];
    ComboBox_GetLBText(dis->hwndItem, dis->itemID, buf);
    if (fPB->GetInt(kResponderStateDef) == dis->itemID)
    {
        char buf2[256];
        sprintf(buf2, "* %s", buf);
        strcpy(buf, buf2);
    }

    ExtTextOut(dis->hDC, x, y, ETO_CLIPPED | ETO_OPAQUE, &dis->rcItem, buf, strlen(buf), NULL); 

    // Restore the previous colors. 
    SetTextColor(dis->hDC, clrForeground); 
    SetBkColor(dis->hDC, clrBackground); 

    if (oldFont)
        DeleteFont(SelectFont(dis->hDC, oldFont));

    // If the item has the focus, draw focus rectangle. 
    if (dis->itemState & ODS_FOCUS) 
        DrawFocusRect(dis->hDC, &dis->rcItem); 
}
Example #20
0
AFX_STATIC void AFXAPI _AfxConvertDialogUnitsToPixels(LPCTSTR pszFontFace, WORD wFontSize,
	int cxDlg, int cyDlg, SIZE* pSizePixel)
{
	// Attempt to create the font to be used in the dialog box
	UINT cxSysChar, cySysChar;
	LOGFONT lf;
	HDC hDC = ::GetDC(NULL);
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = -MulDiv(wFontSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
	lf.lfWeight = FW_NORMAL;
	lf.lfCharSet = DEFAULT_CHARSET;
	Checked::tcsncpy_s(lf.lfFaceName, _countof(lf.lfFaceName), pszFontFace, _TRUNCATE);

	HFONT hNewFont = CreateFontIndirect(&lf);
	if (hNewFont != NULL)
	{
		HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont);
		TEXTMETRIC tm;
		GetTextMetrics(hDC, &tm);
		cySysChar = tm.tmHeight + tm.tmExternalLeading;
		SIZE size;
		::GetTextExtentPoint32(hDC,
			_T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52,
			&size);
		cxSysChar = (size.cx + 26) / 52;
		SelectObject(hDC, hFontOld);
		DeleteObject(hNewFont);
	}
	else
	{
		// Could not create the font so just use the system's values
		cxSysChar = LOWORD(GetDialogBaseUnits());
		cySysChar = HIWORD(GetDialogBaseUnits());
	}
	::ReleaseDC(NULL, hDC);

	// Translate dialog units to pixels
	pSizePixel->cx = MulDiv(cxDlg, cxSysChar, 4);
	pSizePixel->cy = MulDiv(cyDlg, cySysChar, 8);
}
//This virtual function is called to draw the individual columns. In the case of
// non-CBS_HASSTRINGS this has to be implimented in derived classes
void COXMultiComboBox::DrawColumnItem(HDC hDC, int nIndex, int nColIndex, const CRect& rectColumn, int ItemState)
// --- In  : hDC : the DC into which to draw the column
//			 nIndex : The row index
//			 nColIndex : The Column Index
//			 rectColumn : The rectangle into which we can draw
//			 ItemState : Gives the state of the item(Selected or not)
// --- Out : 
// --- Returns : 
// --- Effect : The column text is drawn in the case of CBS_HASSTRINGS
{
	ASSERT(GetStyle()&CBS_HASSTRINGS);

	CDC dc;
	dc.Attach(hDC);
	// Sets the foreground color of the text based on its selection state
	COLORREF clrOldForeground = dc.SetTextColor(::GetSysColor(IsWindowEnabled() ? 
		(ItemState&ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) : 
		COLOR_GRAYTEXT)); 

	COLORREF clrBackground = ::GetSysColor(IsWindowEnabled() ? (ItemState & ODS_SELECTED ? 
COLOR_HIGHLIGHT : COLOR_WINDOW) : COLOR_BTNFACE); 

	// Sets the background color of text based on selection state
	COLORREF clrOldBackground = dc.SetBkColor( clrBackground);

	// Gets  the column text to draw
	CString strText;
	if(nIndex!=-1)
		GetLBText(nIndex,nColIndex,strText);
	else
		strText.Empty();

	CRect cellRect(rectColumn);
	dc.FillSolidRect(cellRect, clrBackground);

	// give left margin
	cellRect.left +=  LOWORD(GetDialogBaseUnits()) / 2;
	// Draw text
	dc.DrawText(strText, cellRect, DT_NOPREFIX | DT_SINGLELINE |
		DT_VCENTER | DT_END_ELLIPSIS);

	// Seperators are drawn in list boxe between columns and rows
	DrawColumnBorder(&dc,rectColumn,ItemState);

	// Reset the actual DC colors
	dc.SetTextColor(clrOldForeground); 
	dc.SetBkColor(clrOldBackground); 
	dc.Detach();
}
Example #22
0
bool IsDialogSizeOK(int xSize, int ySize)
{
  // it returns for system font. Real font uses another values
  LONG v = GetDialogBaseUnits();
  int x = LOWORD(v);
  int y = HIWORD(v);

  RECT rect;
  GetWorkAreaRect(&rect);
  int wx = RECT_SIZE_X(rect);
  int wy = RECT_SIZE_Y(rect);
  return
    xSize / 4 * x <= wx &&
    ySize / 8 * y <= wy;
}
Example #23
0
// create the form and show it (somewhat older style)
void FormLoad (HANDLE hInst)
{
  // get the scale factors
  BCX_GetDiaUnit = GetDialogBaseUnits();
  BCX_cxBaseUnit = LOWORD(BCX_GetDiaUnit);
  BCX_cyBaseUnit = HIWORD(BCX_GetDiaUnit);
  BCX_ScaleX = BCX_cxBaseUnit/4;
  BCX_ScaleY = BCX_cyBaseUnit/8;
  // now the form
  Form1=CreateWindow(AppName,Caption,
    DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU,
    10*BCX_ScaleX,20*BCX_ScaleY,250*BCX_ScaleX,175*BCX_ScaleY,NULL,
    (HMENU)NULL,(HINSTANCE)hInst,NULL);
  Show((HWND)Form1);
}
Example #24
0
void CFontComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	ASSERT( lpDIS->CtlType == ODT_COMBOBOX );

	// make sure this is a *real* item
	if (lpDIS->itemID == -1)
		return;

	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	FONTITEM_PPG* pFI = (FONTITEM_PPG*)lpDIS->itemData;    // pointer to a FONTITEM storied in item data
	LOGFONT* pLF = &pFI->lf;
	COLORREF crBk, crText;
	TEXTMETRIC tm;
	int x, y;

	// Calculate the colors to use
	crBk = pDC->SetBkColor(
		GetSysColor(lpDIS->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_WINDOW) );
	crText = pDC->SetTextColor(
		GetSysColor(lpDIS->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) );

	// Calculate the position of the text
	pDC->GetTextMetrics( &tm );
	x = LOWORD(GetDialogBaseUnits()) / 4;
	y = (lpDIS->rcItem.bottom + lpDIS->rcItem.top - tm.tmHeight) / 2;

	// Draw the text
	pDC->ExtTextOut(lpDIS->rcItem.left + DX_BITMAP + 2 * x, y, ETO_CLIPPED | ETO_OPAQUE,
		&lpDIS->rcItem,(LPCTSTR) pLF->lfFaceName,
		lstrlen((LPCTSTR) pLF->lfFaceName), NULL );

	// Put the colors back as they were
	pDC->SetTextColor( crText );
	pDC->SetBkColor( crBk );

	// Draw the TrueType bitmap
	if (pFI->dwFontType & TRUETYPE_FONTTYPE)
	{
		int dy;
		dy = ((lpDIS->rcItem.bottom - lpDIS->rcItem.top) - DY_BITMAP) / 2;
		_AfxDrawMaskedBitmap(pDC, &m_bmpTrueType, &m_bmpMask,
			x, lpDIS->rcItem.top + dy, DX_BITMAP, DY_BITMAP);
	}

	// Draw the focus rect if needed
	if (lpDIS->itemState & ODS_FOCUS)
		pDC->DrawFocusRect( &lpDIS->rcItem );
}
void CResizableComboBox::UpdateHorizontalExtent(LPCTSTR szText)
{
    CClientDC dc(this);
    CFont* pOldFont = dc.SelectObject(GetFont());

    int cx = dc.GetTextExtent(szText, lstrlen(szText)).cx;
    if (cx > m_iExtent)
    {
        m_iExtent = cx;

        SetHorizontalExtent(m_iExtent
            + LOWORD(GetDialogBaseUnits()));
    }

    dc.SelectObject(pOldFont);
}
Example #26
0
BOOL Dlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) {

   chSETDLGICONS(hwnd, IDI_WFMETEXT);

   // Initialize the controls in the dialog box
   SetDlgItemInt(hwnd,  IDC_NUMOBJS, 4, FALSE);
   SetDlgItemInt(hwnd,  IDC_TIMEOUT, 30000, FALSE);
   SetDlgItemText(hwnd, IDC_EXPRESSION, 
      _T("1 2 | 2 3 4 | 1 4"));

   // Set the multi-column listbox's column size
   ListBox_SetColumnWidth(GetDlgItem(hwnd, IDC_OBJLIST), 
      LOWORD(GetDialogBaseUnits()) * 4);

   return(TRUE);  // Accept default focus window.
}
Example #27
0
/***********************************************************************
 *                    CC_PaintTriangle                        [internal]
 */
static void CC_PaintTriangle( HWND hDlg, int y)
{
 HDC hDC;
 long temp;
 int w = LOWORD(GetDialogBaseUnits()) / 2;
 POINT points[3];
 int height;
 int oben;
 RECT rect;
 HBRUSH hbr;
 HWND hwnd = GetDlgItem(hDlg, 0x2be);
 LPCCPRIV lpp = GetPropW( hDlg, szColourDialogProp );

 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6)))   /* if full size */
 {
   GetClientRect(hwnd, &rect);
   height = rect.bottom;
   hDC = GetDC(hDlg);
   points[0].y = rect.top;
   points[0].x = rect.right;     /*  |  /|  */
   ClientToScreen(hwnd, points); /*  | / |  */
   ScreenToClient(hDlg, points); /*  |<  |  */
   oben = points[0].y;           /*  | \ |  */
                                 /*  |  \|  */
   temp = (long)height * (long)y;
   points[0].x += 1;
   points[0].y = oben + height - temp / (long)MAXVERT;
   points[1].y = points[0].y + w;
   points[2].y = points[0].y - w;
   points[2].x = points[1].x = points[0].x + w;

   hbr = (HBRUSH)GetClassLongPtrW( hwnd, GCLP_HBRBACKGROUND);
   if (!hbr) hbr = GetSysColorBrush(COLOR_BTNFACE);
   FillRect(hDC, &lpp->old3angle, hbr);
   lpp->old3angle.left  = points[0].x;
   lpp->old3angle.right = points[1].x + 1;
   lpp->old3angle.top   = points[2].y - 1;
   lpp->old3angle.bottom= points[1].y + 1;

   hbr = SelectObject(hDC, GetStockObject(BLACK_BRUSH));
   Polygon(hDC, points, 3);
   SelectObject(hDC, hbr);

   ReleaseDC(hDlg, hDC);
 }
}
Example #28
0
File: ui.c Project: DeltaYang/wine
static int create_trailing_edit(HDC hdc, LPDLGITEMTEMPLATEW* template_out, int id,
        int y, LPCSTR text,BOOL is_int)
{
    LPDLGITEMTEMPLATEW tpl =  NULL;
    INT len;
    LPBYTE ptr;
    SIZE size;
    LONG base;
    static const char int_base[] = "0000 xxx";
    static const char float_base[] = "0000.0000 xxx";

    base = GetDialogBaseUnits();

    len = MultiByteToWideChar(CP_ACP,0,text,-1,NULL,0);
    len *= sizeof(WCHAR);
    len += sizeof(DLGITEMTEMPLATE);
    len += 3*sizeof(WORD);

    tpl = HeapAlloc(GetProcessHeap(),0,len);
    tpl->style=WS_VISIBLE|ES_READONLY|WS_BORDER;
    tpl->dwExtendedStyle = 0;
    tpl->x = 1;
    tpl->y = y;
    tpl->id = id;

    if (is_int)
        GetTextExtentPoint32A(hdc,int_base,lstrlenA(int_base),&size);
    else
        GetTextExtentPoint32A(hdc,float_base,lstrlenA(float_base),&size);

    tpl->cx =  MulDiv(size.cx*2,4,LOWORD(base));
    tpl->cy =  MulDiv(size.cy,8,HIWORD(base)) * 2;

    ptr = (LPBYTE)tpl + sizeof(DLGITEMTEMPLATE);
    *(LPWORD)ptr = 0xffff;
    ptr += sizeof(WORD);
    *(LPWORD)ptr = 0x0081;
    ptr += sizeof(WORD);
    ptr += MultiByteToWideChar(CP_ACP,0,text,-1,(LPWSTR)ptr,len) * sizeof(WCHAR);
    *(LPWORD)ptr = 0x0000;

    *template_out = tpl;
    return len;
}
Example #29
0
File: ui.c Project: DeltaYang/wine
static int create_leading_static(HDC hdc, LPCSTR text,
        LPDLGITEMTEMPLATEW* template_out, int y, int id)
{
    LPDLGITEMTEMPLATEW tpl =  NULL;
    INT len;
    SIZE size;
    LPBYTE ptr;
    LONG base;

    *template_out = NULL;

    if (!text)
        return 0;

    base = GetDialogBaseUnits();

    len = MultiByteToWideChar(CP_ACP,0,text,-1,NULL,0);
    len *= sizeof(WCHAR);
    len += sizeof(DLGITEMTEMPLATE);
    len += 3*sizeof(WORD);

    tpl = HeapAlloc(GetProcessHeap(),0,len);
    tpl->style=WS_VISIBLE;
    tpl->dwExtendedStyle = 0;
    tpl->x = 4;
    tpl->y = y;
    tpl->id = ID_BASE;

    GetTextExtentPoint32A(hdc,text,lstrlenA(text),&size);

    tpl->cx =  MulDiv(size.cx,4,LOWORD(base));
    tpl->cy =  MulDiv(size.cy,8,HIWORD(base)) * 2;
    ptr = (LPBYTE)tpl + sizeof(DLGITEMTEMPLATE);
    *(LPWORD)ptr = 0xffff;
    ptr += sizeof(WORD);
    *(LPWORD)ptr = 0x0082;
    ptr += sizeof(WORD);
    ptr += MultiByteToWideChar(CP_ACP,0,text,-1,(LPWSTR)ptr,len) * sizeof(WCHAR);
    *(LPWORD)ptr = 0x0000;

    *template_out = tpl;
    return len;
}
Example #30
0
LRESULT APIENTRY WndProc4(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

    static PARAMS params;

    switch (message)

    {

    case   WM_CREATE:

        params.hwnd = hwnd;

        params.cyChar = HIWORD(GetDialogBaseUnits());

        _beginthread(Thread4, 0, &params);

        return 0;



    case   WM_SIZE:

        params.cxClient = LOWORD(lParam);

        params.cyClient = HIWORD(lParam);

        return 0;



    case   WM_DESTROY:

        params.bKill = TRUE;

        return 0;

    }

    return DefWindowProc(hwnd, message, wParam, lParam);

}