CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: HWND handle

Threaded View

  1. #1
    Join Date
    Aug 2005
    Location
    Barcelona, Spain
    Posts
    40

    HWND handle

    Hi folks!

    I'm working on a MFC project and i've got a question to make. The project i'm involved in, is a dialog based aplication. So, the Wizard took the first steps of the work. I'm basing the program on an example that has been created entirely programming, and it makes reference to a HWND handle variable that is necessary to pass to one of the methods.

    The code is like this:

    Code:
     HRESULT CText::BlendText(HWND hwndApp, TCHAR *szNewText)
    {
        
    	LONG cx, cy;
                    HRESULT hr;
    	CSubtitlesDlg dialog;
    
    	// Create a device context compatible with the current window
    	HDC hdc= GetDC(hwndApp);
    	HDC hdcBmp = CreateCompatibleDC(hdc);
    
    	// Write with a known font by selecting it into our HDC
                    HFONT hOldFont = (HFONT) SelectObject(hdcBmp, g_hFont);
    
    	// Determine the length of the string, then determine the
                    // dimensions (in pixels) of the character string using the
                    // currently selected font.  These dimensions are used to create
                    // a bitmap below.
                    int nLength, nTextBmpWidth, nTextBmpHeight;
                    SIZE sz={0};
    
    	nLength = (int) _tcslen(szNewText);
    	GetTextExtentPoint32(hdcBmp, szNewText, nLength, &sz);
    	nTextBmpHeight = sz.cy;
                    nTextBmpWidth  = sz.cx;
    
                    // Create a new bitmap that is compatible with the current 
                    //window
                    HBITMAP hbm = CreateCompatibleBitmap(hdc, nTextBmpWidth,   
                    nTextBmpHeight);
                    ReleaseDC(hwndApp, hdc);
    
    	// Select our bitmap into the device context and save the old one
                    BITMAP bm;
    	HBITMAP hbmOld;
    	GetObject(hbm, sizeof(bm), &bm);
    	hbmOld = (HBITMAP)SelectObject(hdcBmp, hbm);
     ...
    I make a reference to this method in another class like this:
    Code:
     hr = Text.BlendText(___________, Text.g_szAppText);
    <- I need to know what to put in here

    Does anybody know which method do i need to use in order to get this handle to the window i'm working with? I wonder if the question is clear, but i'll try!! Many thanks. Serj.
    Last edited by Siddhartha; September 29th, 2005 at 09:47 AM. Reason: Added Code-Tags...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured