Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Ribbon Control on Dialog Box
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ribbon Control on Dialog Box

 Post Reply Post Reply
Author
Message
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Topic: Ribbon Control on Dialog Box
    Posted: 30 September 2009 at 11:45pm
Hey I'm trying the trial and when I make the ribbon bar on my dialog box, I create everything in OnInitDialog();. I figure this has something to do with the buttons and everything else on the ribbon bar functioning properly, but I honestly have no clue how I could fix it. When I compile and launch my app, I can click any button, but as soon as I click a button or any sort of control, it all goes grey and I can't click any of them again. Could someone please explain what to do to fix this issue? I imagine its not a big fix, I just can't think of how to do it as I'm completely new to CodeJock and I'm just trying it out.


Please note this is on a dialog, not MDI or SDI.


Edit: Also, when I add the ribbon controls, it adds a lot of extra space to my dialog on the bottom. When I place something at the bottom of the dialog box in the editor and then compile and run, there is a lot of empty space at the bottom. I suppose this is also how I am implementing the code?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2009 at 9:15am
Without seeing your project it is hard to say.  But I can guarantee that it will work, just a matter of seeing what you do wrong.  A few things to try.

Do you handle OnKickIdle?


ON_MESSAGE(WM_KICKIDLE, OnKickIdle)

.....

LRESULT CDialogSampleDlg::OnKickIdle(WPARAM, LPARAM)
{
    if (GetCommandBars()) GetCommandBars()->UpdateCommandBars();
    // If you use status bar
    if (m_wndStatusBar.GetSafeHwnd()) m_wndStatusBar.SendMessage(WM_IDLEUPDATECMDUI, TRUE);
    return 0;
}


As far as the empty space, maybe you need to handle the sizing.


ON_WM_SIZE()

void CDialogSampleDlg::OnSize(UINT nType, int cx, int cy)
{
    CDialogSampleDlgBase::OnSize(nType, cx, cy);
    RepositionControls();
}

void CDialogSampleDlg::RepositionControls()
{
    if (m_bInRepositionControls || !m_bInitDone)
        return;

    CRect rcClientStart;
    CRect rcClientNow;
    GetClientRect(rcClientStart);

    if ((GetStyle() & WS_MINIMIZE) || (rcClientStart.IsRectEmpty()))
        return;

    m_bInRepositionControls = TRUE;

    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, rcClientNow);

    CRect rcBorders(rcClientNow.left - rcClientStart.left, rcClientNow.top - rcClientStart.top,  rcClientStart.right - rcClientNow.right,
        rcClientStart.bottom - rcClientNow.bottom);

    if (rcBorders != m_rcBorders)
    {
       
        CPoint ptOffset(rcBorders.left - m_rcBorders.left, rcBorders.top - m_rcBorders.top);
        CSize szOffset(rcBorders.left + rcBorders.right - m_rcBorders.left - m_rcBorders.right,
            rcBorders.top + rcBorders.bottom - m_rcBorders.top - m_rcBorders.bottom);

        CRect rcWindow;
        GetWindowRect(rcWindow);
        rcWindow.BottomRight() += szOffset;

        Offset(ptOffset);
        m_szWindow += szOffset;
        m_szMin += szOffset;
   
        MoveWindow(rcWindow, TRUE);
    }

    m_rcBorders = rcBorders;

    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

    m_bInRepositionControls = FALSE;
}


Back to Top
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2009 at 11:58am
Hey SuperMario, thank you for your response!

I have attached my project so you can take a look at it, since you said its hard to say without seeing the project. Last night I was up changing stuff around, trying to figure how to fix it, so there may be a few issues somewhere in the code. But I just tried to compile and it compiled just fine. I couldn't figure how to add the code you suggested (when I tried adding it, it wouldn't work). So I figured giving you the source would probably be best.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2009 at 3:35pm
Haven't had time to look at the sample, here is an old one I dug up, I think all you need to do is update the rc2 file with code from a current ribbon sample.

http://forum.codejock.com/uploads/20080917_022718_ds.zip
Back to Top
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Posted: 01 October 2009 at 6:07pm
Originally posted by SuperMario SuperMario wrote:

Haven't had time to look at the sample, here is an old one I dug up, I think all you need to do is update the rc2 file with code from a current ribbon sample.

http://forum.codejock.com/uploads/20080917_022718_ds.zip


I'm getting the exact same issue with that one. And when I attempt to add a 2nd tab and write anything in it, it doesn't appear until I minimize the ribbon control then click on the tab (in which case its still locked out, and it ONLY shows when the ribbon control is supposed to be hidden).


Edit: Everything is now drawing PERFECTLY, but I still can't click it, it keeps everything locked out. And the size issue has been corrected as well.
Back to Top
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2009 at 4:30pm
Sorry for the double post.


Its all drawing perfectly. Now the issue is when I click on the checkbox, it auto-unchecks itself.

When I use the code:

void CDialogSampleDlg::OnCheckbox (UINT nID)
{
       m_bCheckbox[nID - ID_BUTTON_CHECKBOX1] ^= 1;
}


the checkbox's all automatically uncheck themselves (except 3... which is extremely random). And when I use the code:

void CDialogSampleDlg::OnCheckbox (UINT nID)
{
       m_bCheckbox[nID - ID_BUTTON_CHECKBOX1] = 1;
}


then the checkbox stays clicked no matter what (of course, since it equals 1, I just did this to show something is wrong within this function).


I have even tried something like this:

void CDialogSampleDlg::OnCheckbox ()
{
       m_bCheckboxTest ^= 1;
}


and used ON_COMMAND and ON_UPDATE_COMMAND_UI instead (for the OnUpdateCheckbox function). But the same issue occurs. Do you think you may know what is the issue is?

I've also tried:

void CDialogSampleDlg::OnCheckbox ()
{
     if (  m_bCheckboxTest = 0 )
         m_bCheckboxTest = 1;
    else
         m_bCheckboxTest = 0;
}



But again, it doesn't stay checked. Is this just a bug and CodeJock Ribbon controls shouldn't be used on dialog boxes?
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2009 at 9:13am
I don't see where you update the command:

From header:
void OnUpdateViewShowHide(CCmdUI* pCmdUI);
void OnViewShowHide(UINT nID);
BOOL m_bOptions[6];

Source:
ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_RULER, ID_VIEW_THUMBNAILS, OnUpdateViewShowHide)
ON_COMMAND_RANGE(ID_VIEW_RULER, ID_VIEW_THUMBNAILS, OnViewShowHide)

ZeroMemory(&m_bOptions, sizeof(m_bOptions));

void CMainFrame::OnViewShowHide(UINT nID)
{
    m_bOptions[nID - ID_VIEW_RULER] ^= 1;
}

void CDialogSampleDlg::OnUpdateViewShowHide(CCmdUI* pCmdUI)
{
    pCmdUI->SetCheck(m_bOptions[pCmdUI->m_nID - ID_VIEW_RULER] ? TRUE : FALSE);

}

If that don't he;[ post your sample again and we will fix it.
Back to Top
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2009 at 2:26am
Ok its fixed. Thank you! I was forgetting the "? TRUE : FALSE" and the ZeroMemory.

Now one last question ( I think ), when I try to do anything like:

if ( bCheckbox = TRUE )
{
       // Code in here
}


It doesn't work and the code messes up again. Where can I add the code to make my app do something when the checkbox is checked? And I'm actually using:

ON_COMMAND

and
ON_UPDATE_COMMAND_UI


for a single checkbox.

My functions look like:

void CDialogSampleDlg::OnViewShowHide ( )
{
    bCheckbox ^= 1;
}


and

void CDialogSampleDlg::OnUpdateViewShowHide ( CCmdUI* pCmdUI )
{
    pCmdUI->SetCheck ( bCheckbox ? TRUE : FALSE );
}


So how/where would I add code to make it do something when checked? I know I can't put it in OnViewShowHide or OnUpdateViewShowHide, as it messes up and the checkbox doesn't operate properly after that. And when I tried putting the code in OnInitDialog, it of course didn't work. But I was trying any options I had.

Also, I put ZeroMemory in my OnInitDialog. It works, but is that where you wanted me to put it?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 12 October 2009 at 12:39pm

You need

 
if ( bCheckbox == TRUE )
{
       // Code in here
}
 
instead of
 
if ( bCheckbox = TRUE )
{
       // Code in here
}
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
EASX View Drop Down
Newbie
Newbie
Avatar

Joined: 30 September 2009
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote EASX Quote  Post ReplyReply Direct Link To This Post Posted: 12 October 2009 at 3:07pm
Alright thanks, it works perfectly... I felt like the answer was right in front of me. I feel so foolish 
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.189 seconds.