Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to apply menus (xp style) to dialog ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to apply menus (xp style) to dialog ?

 Post Reply Post Reply
Author
Message
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Topic: How to apply menus (xp style) to dialog ?
    Posted: 24 November 2005 at 12:05pm
Hi,

I want to apply office xp style menu to my dialog class.. So, how can i do that ? If i take code form the dialog, it gives error saying, GetCommandBars is not declared.. So, is there any sample of link from where i can find this.. ?

Regards,
Jigar Mehta
Back to Top
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2005 at 12:56pm
Oops..

I got the sampel..

But another questiion is, I want to add a static text to the status bar.. Now, the value of the static text will be updated on runtime.. just like line number of the cursor or like the X and Y co-ordinate of the mouse.. So, how to add that to the status control ?? Any sample for that ? i saw the sample application statusbar but not found how to add the static text to status bar..

Thx
Regards,
Jigar Mehta
Back to Top
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Posted: 24 November 2005 at 2:16pm
Oh.. again i was able to add teh static control to the statusbar.. but it comes on teh menu bar.. 

following is the code i wrote in initdialog function,

    m_wndStatusBar.SetPaneInfo(0, ID_SEPARATOR, SBPS_STRETCH, 100);

    int iIndex = m_wndStatusBar.GetPaneCount();
    m_wndStatusBar.AddIndicator(IDC_STATIC1, iIndex);

    int nIndex = m_wndStatusBar.CommandToIndex(IDC_STATIC1);
    ASSERT (nIndex != -1);
    m_wndStatusBar.SetPaneWidth(nIndex, 100);
    m_wndStatusBar.SetPaneStyle(nIndex, m_wndStatusBar.GetPaneStyle(nIndex) | SBPS_NOBORDERS);
    m_wndStatusBar.AddControl(&m_XPos, IDC_STATIC1, FALSE);

i took one static control made a control variable for that as m_XPos and it shows the static control on menu bar.. instaead of statusbar..

Please tell me what can be the problem.. I tried all teh things.. I debugged then found that PositionBars function called from addcontrol function gets some -18 value for my control as X value.. so, it calculates the value on its own and MoveWindow function moves my window to the menu bar as a result.
Regards,
Jigar Mehta
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2005 at 2:45am

Why you need static text, if you can update text directly to status bar

 

m_wndStatusBar.SetPaneText(...) ?

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2005 at 12:15pm
Thanks,

It helped me.. but still I am adding static control to the status bar..

Because i took code from the sample application, there it was Indicator.. If I change anything in the default struct of the indicator, my program doesnt work properly..

Like if I change,

static UINT indicators[] =
{
    ID_SEPARATOR,         ;   // status line indicator
    ID_INDICATOR_CAPS,
    ID_INDICATOR_NUM,
    ID_INDICATOR_SCRL,
};

to something like this,

static UINT indicators[] =
{
    ID_SEPARATOR,         ;   // status line indicator
    ID_MY_TEXT,
    ID_INDICATOR_CAPS,
    ID_INDICATOR_NUM,
    ID_INDICATOR_SCRL,
};

Program doesnt work properly so, I add my static control to the status bar and doint what i want... so, how can I add the items in the status bar ?

Regards,
Jigar Mehta
Back to Top
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2005 at 2:04pm
Originally posted by oleg oleg wrote:

Why you need static text, if you can update text directly to status bar

 

m_wndStatusBar.SetPaneText(...) ?



What if we want to set the m_wndStatusBar.SetPaneText from a global thread ?? Following is my code for reference..


UINT threadBackgroundTask(LPVOID lParam)
{
    CAppGUIDlg *pDlg;
    pDlg = (CAppGUIDlg *)lParam;

    while(1)
    {
        if(pDlg != NULL)
        {
            pDlg->m_wndStatusBar.SetPaneText(4, "Jigar");
            Sleep(1000);
        }
    }
    return 0;
}

And this thread is started from my dialog,

pBgThread = AfxBeginThread(threadBackgroundTask, this, THREAD_PRIORITY_NORMAL );

where I pass pointer to the dialog to the thread..

Now, the execution gives abort dialog while checking for ASSERT(this)..

So, does it mean that we can not access statusbar object from the global thread.. ?? I can not make the therad as the member of the class.. So, please suggest me the solution..


Regards,
Jigar Mehta
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 November 2005 at 6:45am

SetPaneText can be called only from thread created status bar,

but you can send some message like:

#deifne MY_TEXT_CHANGED (WM_APP + 2)

pDlg->SendMessage(MY_TEXT_CHANGED);

 

and in CAppGUIDlg  catch it and set status text.

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jigarmehtamscit View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2005
Location: India
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote jigarmehtamscit Quote  Post ReplyReply Direct Link To This Post Posted: 26 November 2005 at 1:10pm
Ok.. thx.. I did that and now its working.. Thx for the help..
Regards,
Jigar Mehta
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.063 seconds.