get dialog box size 
Author Message
 get dialog box size

How do i get the size of a dialog box (for CDialog or CFormView) before
 the dialog is created ?

Erwin Brandenberger



Sat, 16 Jun 2001 03:00:00 GMT  
 get dialog box size
Quote:
----- Original Message -----

Newsgroups: microsoft.public.vc,microsoft.public.vc.mfc
Sent: Tuesday, December 29, 1998 10:52 PM
Subject: get dialog box size

>How do i get the size of a dialog box (for CDialog or CFormView) before
> the dialog is created ?

>Erwin Brandenberger

Hi... Erwin Brandenberger... (i'm use english very well.. sorry..)

U Use PreCreateWindow(CREATESTRUCT& cs)  virtual. function

two case working.. one is CDialog base program another CFormView base
Program

- case CDialog
this example make dialog of size 100*100

BOOL CTestDlg::PreCreateWindow(CREATESTRUCT& cs)
{
    //cs.cx --> Dialog width,
    //cs.cy --> Dialog Height
    cs.cx = 100;
    cs.cy = 100;

    return CDialog::PreCreateWindow(cs);
}

- case CFormView
if use CFormView then editing CMainFrame
this example make FrameWnd of size 100*100

BOOL CTestFrm::PreCreateWindow(CREATESTRUCT& cs)
{
    //cs.cx --> Frame window width,
    //cs.cy --> Frame window Height
    cs.cx = 100;
    cs.cy = 100;

    return CMainFrame::PreCreateWindow(cs);
}

---- written by Judoryung from South korea...



Sat, 16 Jun 2001 03:00:00 GMT  
 get dialog box size
Hi, Erwin

You must load the resource of the dialog and call the LockResource
function.

Code for example:

LPCTSTR lpszTemplateName;
lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
 LPCDLGTEMPLATE lpDialogTemplate = NULL;
 HGLOBAL hDialogTemplate = NULL;
 HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
 HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
 hDialogTemplate = LoadResource(hInst, hResource);
 if (hDialogTemplate != NULL)
  lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
 ASSERT(lpDialogTemplate != NULL);

 // free resource
 UnlockResource(hDialogTemplate);
 FreeResource(hDialogTemplate);

Here
nIDTemplate - is ID yours dialog resource.

After LockResource() calling lpDialogTemplate whould be  point to structure

where the sizes are.

George Lozovoy



Sat, 16 Jun 2001 03:00:00 GMT  
 get dialog box size
Now I have the size of the rc file dialog item. How do I get
 the screen coordinate size ?

Erwin Brandenberger

Quote:

> Hi, Erwin

> You must load the resource of the dialog and call the LockResource
> function.

> Code for example:

> LPCTSTR lpszTemplateName;
> lpszTemplateName = MAKEINTRESOURCE(nIDTemplate);
>  LPCDLGTEMPLATE lpDialogTemplate = NULL;
>  HGLOBAL hDialogTemplate = NULL;
>  HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
>  HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
>  hDialogTemplate = LoadResource(hInst, hResource);
>  if (hDialogTemplate != NULL)
>   lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
>  ASSERT(lpDialogTemplate != NULL);

>  // free resource
>  UnlockResource(hDialogTemplate);
>  FreeResource(hDialogTemplate);

> Here
> nIDTemplate - is ID yours dialog resource.

> After LockResource() calling lpDialogTemplate whould be  point to structure

> where the sizes are.

> George Lozovoy

--

+---------------------------------------------------------------------------+
| Erwin Brandenberger                      http://www.ErwinBrandenberger.ch |

| Human Engineering AG                                                      |
| Schoenenbergerweg 9a, 8405 Winterthur-Seen , SWITZERLAND                  |
| CALL: ++41 (0)52-238 07 39  FAX: ++41 (0)52-232 06 20                     |
+---------------------------------------------------------------------------+



Sun, 17 Jun 2001 03:00:00 GMT  
 get dialog box size
I do not want to set the size, I want to GET the size before I create
 the dialog.

Please see George Lozovoy's suggestion.

Erwin Brandenberger

Quote:

> ----- Original Message -----

> Newsgroups: microsoft.public.vc,microsoft.public.vc.mfc
> Sent: Tuesday, December 29, 1998 10:52 PM
> Subject: get dialog box size

> >How do i get the size of a dialog box (for CDialog or CFormView) before
> > the dialog is created ?

> >Erwin Brandenberger

> Hi... Erwin Brandenberger... (i'm use english very well.. sorry..)

> U Use PreCreateWindow(CREATESTRUCT& cs)  virtual. function

> two case working.. one is CDialog base program another CFormView base
> Program

> - case CDialog
> this example make dialog of size 100*100

> BOOL CTestDlg::PreCreateWindow(CREATESTRUCT& cs)
> {
>     //cs.cx --> Dialog width,
>     //cs.cy --> Dialog Height
>     cs.cx = 100;
>     cs.cy = 100;

>     return CDialog::PreCreateWindow(cs);
> }

> - case CFormView
> if use CFormView then editing CMainFrame
> this example make FrameWnd of size 100*100

> BOOL CTestFrm::PreCreateWindow(CREATESTRUCT& cs)
> {
>     //cs.cx --> Frame window width,
>     //cs.cy --> Frame window Height
>     cs.cx = 100;
>     cs.cy = 100;

>     return CMainFrame::PreCreateWindow(cs);
> }

> ---- written by Judoryung from South korea...

--

+---------------------------------------------------------------------------+
| Erwin Brandenberger                      http://www.ErwinBrandenberger.ch |

| Human Engineering AG                                                      |
| Schoenenbergerweg 9a, 8405 Winterthur-Seen , SWITZERLAND                  |
| CALL: ++41 (0)52-238 07 39  FAX: ++41 (0)52-232 06 20                     |
+---------------------------------------------------------------------------+



Sun, 17 Jun 2001 03:00:00 GMT  
 get dialog box size
Is it the screen size your looking for, use GetSystemMetrics with
SM_CXSCREEN
SM_CYSCREEN

/Glenn

Quote:

> Now I have the size of the rc file dialog item. How do I get
>  the screen coordinate size ?

> Erwin Brandenberger



Sun, 17 Jun 2001 03:00:00 GMT  
 get dialog box size

Quote:

> How do i get the size of a dialog box (for CDialog or CFormView) before
>  the dialog is created ?

Try the CDialogTemplate class in afxpriv.h - it used to be undocumented,
I haven't checked to see if they added doc on it since I discovered it
some time ago.  -steve


Sun, 17 Jun 2001 03:00:00 GMT  
 get dialog box size


Quote:
>How do i get the size of a dialog box (for CDialog or CFormView) before
> the dialog is created ?

>Erwin Brandenberger

sorry.. i'm miss take.. before answer..~~~
i'm receive your mail.. retry.. answer...

U use OnCreate override function.. this function called before make window..

U get size..

int CTestDlg::OnCeate(LPCREATESTRUCT lpCreateStruct)
{
    if (CDialog::OnCreate(lpCreateStruct)==-1) retrun -1; // <- this line
make Visual Studio

    CString strTemp;
    strTemp.Format("Width : %d, Height :
%d",lpCreateStruct->cx,lpCreateStruct->cy);
    MessageBox(strTemp); // U see window size before make window

    return 0;

Quote:
}

i'm sorry... miss-answer..
thanks you mail..~~

written Judoryung  from s.Korea....

PS : my speak english skill ---> oh.....no....english...
ha...ha...ho...ho..  T.T (Crying Face)..



Mon, 18 Jun 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Getting Dialog or FormView sizes from Resources

2. Getting Dialog or FormView sizes from Resources

3. dialog size in evc++ dialog editor not the same as size in pixels on device

4. Get size of dialog box

5. Sizing Dialog Box

6. How to change the color,size,font of text in a dialog box

7. Dialog box sizing

8. Sizing of controls in Dialog Box

9. Getting Handle from a PicBox on a Dialog Box

10. How to refresh my dialog box whenever it gets focus after changes in Registry

11. Getting a CMap from Doc to a Dialog box

12. font size of dialog box

 

 
Powered by phpBB® Forum Software