Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. resizing dialog box

resizing dialog box

Scheduled Pinned Locked Moved C / C++ / MFC
helplearning
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haseeb_saeed
    wrote on last edited by
    #1

    Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb

    K J 2 Replies Last reply
    0
    • H haseeb_saeed

      Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb

      K Offline
      K Offline
      kdehairy
      wrote on last edited by
      #2

      well .. sizing a dialog is a little bit deferent than other kind of windows, because of its measuring units. In a dialog when you say that width = 100, it doesn't mean 100 pixels (!!) it means 100 dialog units (depends on the font you are using in the dialog). open user dialog resource in the visual c++ and look at the status bar (right most), you will find the size of your dialog in dialog units. so, 1- write down size of your dialog when in the scientific mode (from the status bar), these are in the dialog measuring units. 2- ... CRect rect; rect.left = 0; rect.top = 0; //replace Width with the value of width you wrote rect.right = Width; //replace Height with the value of height you wrote rect.bottom = Height; //Call this function which converts the dialog units //into pixel units and pass it a pointer to rect MapDialogRect(&rect); now you have the new size in pixel units. you can use it freely. 3- Call the function SetWindowPos() and give it the width and height of the rect. I suggest you move with the debugger to watch the change in the units after the MapDialogRect() call. hope it is helpfull good luck k_dehairy

      H 1 Reply Last reply
      0
      • H haseeb_saeed

        Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit.... thankyou haseeb

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        Actualy the Windows calculator probably does not resize at all. It most likely consist of 2 different dialog boxes. When the user decides to switch caculator views, that is what it does. 1) Create 2 dialog boxes: normal and scientific. Remember to use the same IDs for the buttons, etc... that do the same thing. 2) Create a CDialog based class for the scientific dialog only, since you only need one class to handle all the commands. 3) Now when the user selects a new veiw call EndDialog(some known value). Example:

        if( dialogID == IDD_NORMAL )
        EndDialog(IDD_SCIENTIFIC).
        else
        EndDialog(IDD_NORMAL).

        1. Finaly your code calling DoModal() (to show your dialog) needs to look something like this:

        ...
        int result = IDD_NORMAL.
        do {
        if( result != IDD_NORMAL || result != IDD_SCIENTIFIC )
        break; // something happen that should not have
        { // required
        CMyDialog dlg(result);
        result = dlg.DoModal
        } // dlg destroyed here
        // FYI: IDOK = 1, IDCANCEL = 2
        } while( result != IDOK && result != IDCANCEL );

        Any way that is most likely how I would do it. You ought to be able to figure out the rest. Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen

        H 1 Reply Last reply
        0
        • K kdehairy

          well .. sizing a dialog is a little bit deferent than other kind of windows, because of its measuring units. In a dialog when you say that width = 100, it doesn't mean 100 pixels (!!) it means 100 dialog units (depends on the font you are using in the dialog). open user dialog resource in the visual c++ and look at the status bar (right most), you will find the size of your dialog in dialog units. so, 1- write down size of your dialog when in the scientific mode (from the status bar), these are in the dialog measuring units. 2- ... CRect rect; rect.left = 0; rect.top = 0; //replace Width with the value of width you wrote rect.right = Width; //replace Height with the value of height you wrote rect.bottom = Height; //Call this function which converts the dialog units //into pixel units and pass it a pointer to rect MapDialogRect(&rect); now you have the new size in pixel units. you can use it freely. 3- Call the function SetWindowPos() and give it the width and height of the rect. I suggest you move with the debugger to watch the change in the units after the MapDialogRect() call. hope it is helpfull good luck k_dehairy

          H Offline
          H Offline
          haseeb_saeed
          wrote on last edited by
          #4

          thanx alot ... probably now i would be able to achieve my goal.... thanx... haseeb haseeb

          1 Reply Last reply
          0
          • J John R Shaw

            Actualy the Windows calculator probably does not resize at all. It most likely consist of 2 different dialog boxes. When the user decides to switch caculator views, that is what it does. 1) Create 2 dialog boxes: normal and scientific. Remember to use the same IDs for the buttons, etc... that do the same thing. 2) Create a CDialog based class for the scientific dialog only, since you only need one class to handle all the commands. 3) Now when the user selects a new veiw call EndDialog(some known value). Example:

            if( dialogID == IDD_NORMAL )
            EndDialog(IDD_SCIENTIFIC).
            else
            EndDialog(IDD_NORMAL).

            1. Finaly your code calling DoModal() (to show your dialog) needs to look something like this:

            ...
            int result = IDD_NORMAL.
            do {
            if( result != IDD_NORMAL || result != IDD_SCIENTIFIC )
            break; // something happen that should not have
            { // required
            CMyDialog dlg(result);
            result = dlg.DoModal
            } // dlg destroyed here
            // FYI: IDOK = 1, IDCANCEL = 2
            } while( result != IDOK && result != IDCANCEL );

            Any way that is most likely how I would do it. You ought to be able to figure out the rest. Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen

            H Offline
            H Offline
            haseeb_saeed
            wrote on last edited by
            #5

            thank you.... i hope now i would figure out a way to solve the problem... haseeb

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups