Print Page | Close Window

CMainFrame not skinned

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=16014
Printed Date: 22 November 2024 at 1:44pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CMainFrame not skinned
Posted By: feffe
Subject: CMainFrame not skinned
Date Posted: 15 January 2010 at 4:37am
Hi,
 
I'd like that every window of my application to be skinned, but not my CMainFrame.
 
I call XTPSkinManager()->AutoApplyNewWindows(TRUE) and XTPSkinManager()->LoadSkin(...)
in CMainFrame constructor.
 
Then, in CMainFrame::OnCreate, I call XTPSkinManager()->Remove(m_hWnd) but it doesn't seem to work.
 
Where am I wrong?
 
Thanks a lot



Replies:
Posted By: feffe
Date Posted: 18 January 2010 at 12:28pm
 
...Any idea?
 
My app is too slow if I have the mainframe skinned...


Posted By: znakeeye
Date Posted: 19 January 2010 at 7:30am
My idea: that's impossible
 
Are you sure CMainFrame is the window being skinned?
Perhaps you have some MDI children that occupy the view and makes it look like the main frame is skinned?
 
Try stepping into CXTPSkinManager::Remove and see what goes wrong...


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: feffe
Date Posted: 20 January 2010 at 2:46am
 
I've tried to study the problem...
And I've seen that the call AutoApplyNewWindow(TRUE) really slows down my program.
 
So...
Is there a method for having skinned dialo without calling it?
My problem is especially when I need calling "afxmessagebox..."...
 
Any suggestion?
 
EDIT: I think I've the same problem already explained in the thread
http://forum.codejock.com/forum_posts.asp?TID=15346 - http://forum.codejock.com/forum_posts.asp?TID=15346
 
 
 


Posted By: znakeeye
Date Posted: 21 January 2010 at 10:06am

AfxMessageBox is tricky...

 
HHOOK    CYourApp::s_hMsgBoxHook = NULL;
LRESULT CALLBACK CYourApp::CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
    if (nCode < 0)
        return CallNextHookEx(s_hMsgBoxHook, nCode, wParam, lParam);
    if (nCode == HCBT_CREATEWND)
    {
        UnhookWindowsHookEx(s_hMsgBoxHook);
        s_hMsgBoxHook = NULL;
        XTPSkinManager()->ApplyWindow((HWND)wParam);
        return 0;
    }
    // Call the next hook, if there is one.
    return CallNextHookEx(s_hMsgBoxHook, nCode, wParam, lParam);
}
int CYourApp::DoMessageBox(LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt)
{
    // Install a window hook, so we can intercept the message-box creation, and customize it.
    s_hMsgBoxHook = SetWindowsHookEx(WH_CBT, CBTProc, NULL, GetCurrentThreadId());
   
    // Display a standard message box.
    int retVal = CWinApp::DoMessageBox(lpszPrompt, nType, nIDPrompt);
    // Remove the window hook!
    if (s_hMsgBoxHook)
        UnhookWindowsHookEx(s_hMsgBoxHook);
   
    return retVal;
}
 
Anyway, are you absolutely sure that AutoApplyNewWindows is the culprit? If that is the case, I would really like to avoid it myself. Haven't seen problems with it so far though.


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: feffe
Date Posted: 22 January 2010 at 2:41am
 
Thank you very much znakeeye...
 
Contextmenus are the part of my application that really slows down...
 
So, perhaps, can I leave the "AutoAplly" call and disactivate any aspect of the skin when I show contextmenus?
 
Thank you


Posted By: znakeeye
Date Posted: 22 January 2010 at 6:02am
I don't see how a context menu could slow things down. Please post code that you run when displaying a context menu!
 
Is it possible that one of your update-handlers goes nuts? E.g. enabling -> disabling -> enabling -> disabling...?


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: feffe
Date Posted: 22 January 2010 at 6:07am
 
Afraid the problem is that I'm using also MFC Feature Pack classes.
 
The method you've explained me in the previous post (with CBTProc)
could be used also for EVERY kind of window, not only message boxes?
 
In this way, I try to avoid the call to AutoApply but I obtain the same effect. 
 
EDIT: your method doesn't skin buttons of messageboxes.
Maybe missed to set an option?
 
Thanks a lot!!


Posted By: znakeeye
Date Posted: 22 January 2010 at 7:37am
The skin-engine is activated on a "per-window" basis. You need to add all child-windows too. I guess you can enumerate the children of the messagebox window, but this means you've essentially implemented the same hooking functionality that Codejock already has (although this would only be for message boxes).
 
For your own windows, a hook is not necessary. All you need is to handle CYourWnd::OnCreate(...) and add m_hWnd to the skin-manager.


-------------
PokerMemento - http://www.pokermemento.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net