Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - CMainFrame not skinned
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CMainFrame not skinned

 Post Reply Post Reply
Author
Message
feffe View Drop Down
Groupie
Groupie


Joined: 04 September 2009
Status: Offline
Points: 56
Post Options Post Options   Thanks (0) Thanks(0)   Quote feffe Quote  Post ReplyReply Direct Link To This Post Topic: CMainFrame not skinned
    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
Back to Top
feffe View Drop Down
Groupie
Groupie


Joined: 04 September 2009
Status: Offline
Points: 56
Post Options Post Options   Thanks (0) Thanks(0)   Quote feffe Quote  Post ReplyReply Direct Link To This Post Posted: 18 January 2010 at 12:28pm
 
...Any idea?
 
My app is too slow if I have the mainframe skinned...
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
feffe View Drop Down
Groupie
Groupie


Joined: 04 September 2009
Status: Offline
Points: 56
Post Options Post Options   Thanks (0) Thanks(0)   Quote feffe Quote  Post ReplyReply Direct Link To This Post 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
 
 
 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
feffe View Drop Down
Groupie
Groupie


Joined: 04 September 2009
Status: Offline
Points: 56
Post Options Post Options   Thanks (0) Thanks(0)   Quote feffe Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
feffe View Drop Down
Groupie
Groupie


Joined: 04 September 2009
Status: Offline
Points: 56
Post Options Post Options   Thanks (0) Thanks(0)   Quote feffe Quote  Post ReplyReply Direct Link To This Post 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!!
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.184 seconds.