"anonymous@discussions.microsoft.com"
<lewix@discussions.microsoft.com>
wrote in message
news:5c171357-414c-4815-a105-05f8076d448d_WBRev3_@discussions.microsoft.com
> This post has been edited either by the author or a moderator in the
> Microsoft Forums: http://forums.microsoft.com Hi,
> i hope i'm not posting a newbie question.
> I have to get current DC handler of my window dialog, so (as
> suggested on most forums on the net) i use GetDC() function.
> It is explained (in MSDN site too) GetDC has one argument: HWND hWnd.
> But if i type
> HDC hDC = GetDC(m_hWnd)
> on my project, the compiler returns this error: "GetDC function
> doesn't accepts arguments".
> In fact the intellisense of my Visual Studio .net (2003) suggests me:
> "this->GetDC()", not "this->GetDC(HWND hWnd)"
wrote in message
news:5c171357-414c-4815-a105-05f8076d448d_WBRev3_@discussions.microsoft.com
> This post has been edited either by the author or a moderator in the
> Microsoft Forums: http://forums.microsoft.com Hi,
> i hope i'm not posting a newbie question.
> I have to get current DC handler of my window dialog, so (as
> suggested on most forums on the net) i use GetDC() function.
> It is explained (in MSDN site too) GetDC has one argument: HWND hWnd.
> But if i type
> HDC hDC = GetDC(m_hWnd)
> on my project, the compiler returns this error: "GetDC function
> doesn't accepts arguments".
> In fact the intellisense of my Visual Studio .net (2003) suggests me:
> "this->GetDC()", not "this->GetDC(HWND hWnd)"
MFC's CWnd class (from which your dialog class is ultimately derived) is a
wrapper around HWND, and holds an HWND as a member variable. For almost every
Win32 API of the form SomeFunction(HWND hwnd, moreParameters), CWnd has a
matching member function SomeFunction(moreParameters), which most of the time
simply forwards to the API passing m_hWnd as the first parameter.
So, inside a method of CWnd-derived class, GetDC refers to CWnd::GetDC().
If for some reason you insist on calling the raw API function, you can do it
with ::GetDC(someHWND). Note that CWnd::GetDC() simply calls ::GetDC(m_hWnd),
which is likely what you want anyway.
--
With best wishes,
Igor Tandetnik
--
With best wishes,
Igor Tandetnik

GetDC function
trixter
wrote in message
news:688985c4-d678-4309-84a9-dfbb5d58ec8d_WBRev2_@discussions.microsoft.com
> Thanx a lot!, [:)]
> i have just found out the solution me too (calling ::GetDC(m_hWnd),
> but you explained the "why" of this problem.
> I had to use ::GetDC(HWND hWnd) because this function returns HDC
> variable that i will need on my application.
> CWnd::GetDC(void) returns pointer to CDC [:S]
--
With best wishes,
Igor Tandetnik
fanse
BOOL CLewixXpDlg::OnEraseBkgnd(CDC* pDC)
{
.......................
.........................................
// TODO: aggiungere qui il codice per la gestione dei messaggi e/o chiamare il codice predefinito.
HINSTANCE hFI = LoadLibrary("FreeImage.dll");
if (hFI==NULL)
return CDialog::OnEraseBkgnd(pDC);
...........................
.........................
.............
/*if functions linked don't point NULL...*/
{
CRect rcDest;
GetClientRect(rcDest);
FIBITMAP *dib = pFreeImage_Load(FIF_PNG, "c:\\push.png", 0);
SetStretchBltMode(pDC->m_hDC, COLORONCOLOR);
StretchDIBits(pDC->m_hDC, rcDest.left, rcDest.top,
rcDest.right-rcDest.left, rcDest.bottom-rcDest.top,
0, 0, pFreeImage_GetWidth(dib), pFreeImage_GetHeight(dib),
pFreeImage_GetBits(dib), pFreeImage_GetInfo(dib),
DIB_RGB_COLORS, SRCCOPY);
pFreeImage_Unload(dib);
}
FreeLibrary(hFI);
return TRUE;
}
It's works, i have still to check it but i hope there aren't critical errors...
Lewix
SSCIT
you're right.
Sorry but i'm working with MFC for few months, but i like it, it isn't easy but it is very coherent framework.
Thanx for explaining, really.
Lewix
shumona
WTL I noticed some discussion about it some forum.
Wow... WTL is also opensource (great sourceforge).
Thanx for the links you give me; now i'm on wtl home page....
Mmmm.. good.
Ok, you'll have news about opinion, thanx for your help on this thread.
Lewix
Konigmann
i hope i'm not posting a newbie question.
I have to get current DC handler of my window dialog, so (as suggested on most forums on the net) i use GetDC() function.
It is explained (in MSDN site too) GetDC has one argument: HWND hWnd.
But if i type
HDC hDC = GetDC(m_hWnd)
on my project, the compiler returns this error: "GetDC function doesn't accepts arguments".
In fact the intellisense of my Visual Studio .net (2003) suggests me:
"this->GetDC()", not "this->GetDC(HWND hWnd)"
Why this happens What is the solution
Thanx to anybody can help me.
Lewix
P.S.: my project is a MFC application, standard single dialog, dll shared.
donaldg
wrote in message
news:c5cbaa61-f087-405e-ac5e-0fa73189c7b7@discussions.microsoft.com
> I show you the code where i need to use HDC variable (i have to
> change dialog background image, using FreeImage library dll):
>
> SetStretchBltMode(pDC->m_hDC, COLORONCOLOR);
> StretchDIBits(pDC->m_hDC, ...);
--
With best wishes,
Igor Tandetnik
JayZee
wrote in message
news:15d3d04e-6da2-4f19-a6c5-1458418dff35_WBRev1_@discussions.microsoft.com
> Sorry but i'm working with MFC for few months, but i like it, it
> isn't easy but it is very coherent framework.
--
With best wishes,
Igor Tandetnik
jmsigler2
i have just found out the solution me too (calling ::GetDC(m_hWnd), but you explained the "why" of this problem.
I had to use ::GetDC(HWND hWnd) because this function returns HDC variable that i will need on my application.
CWnd::GetDC(void) returns pointer to CDC
If exist other solutions to get hDC from a dialog tell me of course!!
Thanx again
Lewix
LinCar
I have to be more "open mind" :)
Thanx again!
Lewix