Click here to Skip to main content
15,913,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CreateProcess( ) :o) Pin
Danny Blanchard6-Mar-03 10:10
Danny Blanchard6-Mar-03 10:10 
GeneralRe: CreateProcess( ) :o) Pin
Blake Miller7-Mar-03 9:44
Blake Miller7-Mar-03 9:44 
GeneralCustom controls in an exported DLL Pin
DREVET Olivier6-Mar-03 8:54
DREVET Olivier6-Mar-03 8:54 
GeneralRe: Custom controls in an exported DLL Pin
Bartosz Bien6-Mar-03 12:33
Bartosz Bien6-Mar-03 12:33 
GeneralRe: Custom controls in an exported DLL Pin
DREVET Olivier6-Mar-03 13:06
DREVET Olivier6-Mar-03 13:06 
GeneralRe: Custom controls in an exported DLL Pin
Bartosz Bien7-Mar-03 0:33
Bartosz Bien7-Mar-03 0:33 
GeneralRe: Custom controls in an exported DLL Pin
DREVET Olivier7-Mar-03 0:48
DREVET Olivier7-Mar-03 0:48 
GeneralRe: Custom controls in an exported DLL Pin
Bartosz Bien7-Mar-03 1:07
Bartosz Bien7-Mar-03 1:07 
There's an important issue here: MFC extension DLLs maintain their own resource handle.

Personally I call such function in the C++ constructor of all my custom controls (I modified it slightly to fit your question):

BOOL CMyCustomCtrl::RegisterClass()<br />
{<br />
    WNDCLASS wndcls;<br />
    HINSTANCE hInst = AfxGetResourceHandle();<br />
<br />
    if(!(GetClassInfo(hInst, "MyWndClassName", &wndcls)))<br />
    {<br />
        wndcls.style            = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;<br />
        wndcls.lpfnWndProc      = ::DefWindowProc;<br />
        wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;<br />
        wndcls.hInstance        = hInst;<br />
        wndcls.hIcon            = NULL;<br />
        wndcls.hCursor          = LoadCursor(NULL, IDC_ARROW);<br />
        wndcls.hbrBackground    = NULL;<br />
        wndcls.lpszMenuName     = NULL;<br />
        wndcls.lpszClassName    = "MyWndClassName";<br />
<br />
        if(!AfxRegisterClass(&wndcls))<br />
	{<br />
            AfxThrowResourceException();<br />
            return FALSE;<br />
        }<br />
    }<br />
    return TRUE;<br />
}


The function checks whether the control is registered with current resource handle, and registers it if not yet done. This way we cover both the application and DLL case. The function can be universal if you derive your custom controls from the common base class and use "MyWndClassName" as a function argument.

You may read in the MSDN what the several WNDCLASS members mean, and the code is self-commenting I guess. I hope I didn't miss anything in this explanation, but ask if there's turn out wrong. Smile | :)

Regards,
BB
GeneralRe: Custom controls in an exported DLL Pin
DREVET Olivier7-Mar-03 1:21
DREVET Olivier7-Mar-03 1:21 
GeneralRe: Custom controls in an exported DLL Pin
DREVET Olivier7-Mar-03 4:34
DREVET Olivier7-Mar-03 4:34 
GeneralRe: Custom controls in an exported DLL Pin
Bartosz Bien7-Mar-03 4:49
Bartosz Bien7-Mar-03 4:49 
GeneralDynamic creation (instanciation) of classes Pin
dherrero6-Mar-03 8:35
dherrero6-Mar-03 8:35 
GeneralRe: Dynamic creation (instanciation) of classes Pin
Ravi Bhavnani6-Mar-03 8:37
professionalRavi Bhavnani6-Mar-03 8:37 
GeneralRe: Dynamic creation (instanciation) of classes Pin
dherrero6-Mar-03 12:11
dherrero6-Mar-03 12:11 
GeneralAdd about to system menu in dialog box Pin
jimNLX6-Mar-03 8:27
jimNLX6-Mar-03 8:27 
GeneralRe: Add about to system menu in dialog box Pin
Ravi Bhavnani6-Mar-03 8:35
professionalRavi Bhavnani6-Mar-03 8:35 
GeneralRe: Add about to system menu in dialog box Pin
jimNLX6-Mar-03 8:37
jimNLX6-Mar-03 8:37 
GeneralRe: Add about to system menu in dialog box Pin
jimNLX6-Mar-03 9:12
jimNLX6-Mar-03 9:12 
QuestionDiffernance between MFC extension DL L and regular mfc dll? Pin
clintsinger6-Mar-03 8:17
clintsinger6-Mar-03 8:17 
AnswerRe: Differnance between MFC extension DL L and regular mfc dll? Pin
Bartosz Bien6-Mar-03 12:35
Bartosz Bien6-Mar-03 12:35 
GeneralTransparent Icons Pin
jimNLX6-Mar-03 8:17
jimNLX6-Mar-03 8:17 
GeneralRe: Transparent Icons Pin
DREVET Olivier7-Mar-03 3:10
DREVET Olivier7-Mar-03 3:10 
GeneralSDK & DDK Pin
jucanpo6-Mar-03 7:58
jucanpo6-Mar-03 7:58 
GeneralRe: SDK & DDK Pin
Chris Richardson6-Mar-03 9:35
Chris Richardson6-Mar-03 9:35 
GeneralLines count Pin
Anonymous6-Mar-03 7:49
Anonymous6-Mar-03 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.