Board index » Visual Studio » Working with CStatic!

Working with CStatic!

Visual Studio211
Hello,

I have a dialog based application and i have 4 square "frames"

symetrically filling the client area of the main dialog box .



Each frame is meant to receive picture from a camera. I have added 4 CStatic

member

objects to the dialog class to be able to dynamically act on the frames.



My objecs are :

CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;



The ressource IDs are appropriately connected to the respectives

CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

so one....



I want to dynamically control the postions of the frame. so i did:

CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);





//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);







IM THEN EXPECTING TO SEE MY FIRST

FRAME IN THE LEFT UPPER CORNER OF

THE DIALOG BOX.

BUT NOTHING IS DISPLAYED THERE.



CAN SOMEONE HELP ME FIND OUT WHAT

I'M DOING WRONG?


-
 

Re:Working with CStatic!

I'm doing this on the OnPaint(... event







"Bredal Jensen" <Bredal.Jensen@mimosa.com>wrote in message

Quote




Hello,

I have a dialog based application and i have 4 square "frames"

symetrically filling the client area of the main dialog box .



Each frame is meant to receive picture from a camera. I have added 4

CStatic

member

objects to the dialog class to be able to dynamically act on the frames.



My objecs are :

CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;



The ressource IDs are appropriately connected to the respectives

CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

so one....



I want to dynamically control the postions of the frame. so i did:

CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);





//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);







IM THEN EXPECTING TO SEE MY FIRST

FRAME IN THE LEFT UPPER CORNER OF

THE DIALOG BOX.

BUT NOTHING IS DISPLAYED THERE.



CAN SOMEONE HELP ME FIND OUT WHAT

I'M DOING WRONG?









-

Re:Working with CStatic!

Initialize your temp rect with ::GetClientRect(m_frame1.m_hWnd

,&temp_rect);



try following:



CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);

::GetClientRect(m_frame1.m_hWnd ,&temp_rect); //Insert this line



//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);



--------------------------------------------

Manish Agarwal <manishkrishan@hotmail.com>

personal.vsnl.com/mkag">personal.vsnl.com/mkag





"Bredal Jensen" <Bredal.Jensen@mimosa.com>wrote in message

Quote




Hello,

I have a dialog based application and i have 4 square "frames"

symetrically filling the client area of the main dialog box .



Each frame is meant to receive picture from a camera. I have added 4

CStatic

member

objects to the dialog class to be able to dynamically act on the frames.



My objecs are :

CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;



The ressource IDs are appropriately connected to the respectives

CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

so one....



I want to dynamically control the postions of the frame. so i did:

CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);





//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);







IM THEN EXPECTING TO SEE MY FIRST

FRAME IN THE LEFT UPPER CORNER OF

THE DIALOG BOX.

BUT NOTHING IS DISPLAYED THERE.



CAN SOMEONE HELP ME FIND OUT WHAT

I'M DOING WRONG?









-

Re:Working with CStatic!

Bredal Jensen wrote:



Quote
Hello,

I have a dialog based application and i have 4 square "frames"

symetrically filling the client area of the main dialog box .



Each frame is meant to receive picture from a camera. I have added 4 CStatic

member

objects to the dialog class to be able to dynamically act on the frames.



My objecs are :

CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;



The ressource IDs are appropriately connected to the respectives

CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

so one....



I want to dynamically control the postions of the frame. so i did:

CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);





//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);







IM THEN EXPECTING TO SEE MY FIRST

FRAME IN THE LEFT UPPER CORNER OF

THE DIALOG BOX.

BUT NOTHING IS DISPLAYED THERE.



CAN SOMEONE HELP ME FIND OUT WHAT

I'M DOING WRONG?







(1) Don't do this in OnPaint(). Moving a child in OnPaint will cause

another OnPaint(). You can reposition controls in OnInitDialog, or in

OnSize if the dialog is resizeable.

(2) temp_rect.right is uninitialized == garbage

(3) rect.left is 0 by definition. Why are you dividing this by 2 and

subtracting 5?

(4) No purpose is served by calling the GetClientRect API instead of the

member function. Ugly!



--

Scott McPhillips [VC++ MVP]



-

Re:Working with CStatic!

The code had no effect!









"Manish Agarwal" <manish.agarwal@mphasis.com>wrote in message

Quote
Initialize your temp rect with ::GetClientRect(m_frame1.m_hWnd

,&temp_rect);



try following:



CRect rect , temp_rect;

::GetClientRect(this->m_hWnd ,&rect);

::GetClientRect(m_frame1.m_hWnd ,&temp_rect); //Insert this line



//Display "window1" on the left up corner .

temp_rect.top=rect.top+5;

temp_rect.left=(rect.left/2)-5;

temp_rect.bottom=(rect.bottom/2)- 5;





m_frame1.MoveWindow(&temp_rect,true);

m_frame1.ShowWindow(SW_SHOW);



--------------------------------------------

Manish Agarwal <manishkrishan@hotmail.com>

personal.vsnl.com/mkag">personal.vsnl.com/mkag





"Bredal Jensen" <Bredal.Jensen@mimosa.com>wrote in message

news:OzNDBe3gEHA.3916@TK2MSFTNGP11.phx.gbl...

>

>

>Hello,

>I have a dialog based application and i have 4 square "frames"

>symetrically filling the client area of the main dialog box .

>

>Each frame is meant to receive picture from a camera. I have added 4

CStatic

>member

>objects to the dialog class to be able to dynamically act on the frames.

>

>My objecs are :

>CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;

>

>The ressource IDs are appropriately connected to the respectives

>CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

>so one....

>

>I want to dynamically control the postions of the frame. so i did:

>CRect rect , temp_rect;

>::GetClientRect(this->m_hWnd ,&rect);

>

>

>//Display "window1" on the left up corner .

>temp_rect.top=rect.top+5;

>temp_rect.left=(rect.left/2)-5;

>temp_rect.bottom=(rect.bottom/2)- 5;

>

>

>m_frame1.MoveWindow(&temp_rect,true);

>m_frame1.ShowWindow(SW_SHOW);

>

>

>

>IM THEN EXPECTING TO SEE MY FIRST

>FRAME IN THE LEFT UPPER CORNER OF

>THE DIALOG BOX.

>BUT NOTHING IS DISPLAYED THERE.

>

>CAN SOMEONE HELP ME FIND OUT WHAT

>I'M DOING WRONG?

>

>









-

Re:Working with CStatic!

Move your code to OnInitDialog



"Bredal Jensen" <Bredal.Jensen@mimosa.com>wrote in message

Quote
The code had no effect!









"Manish Agarwal" <manish.agarwal@mphasis.com>wrote in message

news:uRvaGD4gEHA.636@TK2MSFTNGP12.phx.gbl...

>Initialize your temp rect with ::GetClientRect(m_frame1.m_hWnd

>,&temp_rect);

>

>try following:

>

>CRect rect , temp_rect;

>::GetClientRect(this->m_hWnd ,&rect);

>::GetClientRect(m_frame1.m_hWnd ,&temp_rect); //Insert this line

>

>//Display "window1" on the left up corner .

>temp_rect.top=rect.top+5;

>temp_rect.left=(rect.left/2)-5;

>temp_rect.bottom=(rect.bottom/2)- 5;

>

>

>m_frame1.MoveWindow(&temp_rect,true);

>m_frame1.ShowWindow(SW_SHOW);

>

>--------------------------------------------

>Manish Agarwal <manishkrishan@hotmail.com>

>personal.vsnl.com/mkag">personal.vsnl.com/mkag

>

>

>"Bredal Jensen" <Bredal.Jensen@mimosa.com>wrote in message

>news:OzNDBe3gEHA.3916@TK2MSFTNGP11.phx.gbl...

>>

>>

>>Hello,

>>I have a dialog based application and i have 4 square "frames"

>>symetrically filling the client area of the main dialog box .

>>

>>Each frame is meant to receive picture from a camera. I have added 4

>CStatic

>>member

>>objects to the dialog class to be able to dynamically act on the

frames.

>>

>>My objecs are :

>>CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;

>>

>>The ressource IDs are appropriately connected to the respectives

>>CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

>>so one....

>>

>>I want to dynamically control the postions of the frame. so i did:

>>CRect rect , temp_rect;

>>::GetClientRect(this->m_hWnd ,&rect);

>>

>>

>>//Display "window1" on the left up corner .

>>temp_rect.top=rect.top+5;

>>temp_rect.left=(rect.left/2)-5;

>>temp_rect.bottom=(rect.bottom/2)- 5;

>>

>>

>>m_frame1.MoveWindow(&temp_rect,true);

>>m_frame1.ShowWindow(SW_SHOW);

>>

>>

>>

>>IM THEN EXPECTING TO SEE MY FIRST

>>FRAME IN THE LEFT UPPER CORNER OF

>>THE DIALOG BOX.

>>BUT NOTHING IS DISPLAYED THERE.

>>

>>CAN SOMEONE HELP ME FIND OUT WHAT

>>I'M DOING WRONG?

>>

>>

>

>









-

Re:Working with CStatic!

well thank you,

i found what i was doing wrong.



I have an other issue. I want to add an Icon bar to

the respective frames. Is there a way to do this ?







"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>wrote in message

Quote
Bredal Jensen wrote:



>Hello,

>I have a dialog based application and i have 4 square "frames"

>symetrically filling the client area of the main dialog box .

>

>Each frame is meant to receive picture from a camera. I have added 4

CStatic

>member

>objects to the dialog class to be able to dynamically act on the frames.

>

>My objecs are :

>CStatic m_frame1,m_frame_2 ,m_frame3, m_frame4;

>

>The ressource IDs are appropriately connected to the respectives

>CStatics objecs DDX_Control(pDX, IDC_STATIC1, m_frame1); and

>so one....

>

>I want to dynamically control the postions of the frame. so i did:

>CRect rect , temp_rect;

>::GetClientRect(this->m_hWnd ,&rect);

>

>

>//Display "window1" on the left up corner .

>temp_rect.top=rect.top+5;

>temp_rect.left=(rect.left/2)-5;

>temp_rect.bottom=(rect.bottom/2)- 5;

>

>

>m_frame1.MoveWindow(&temp_rect,true);

>m_frame1.ShowWindow(SW_SHOW);

>

>

>

>IM THEN EXPECTING TO SEE MY FIRST

>FRAME IN THE LEFT UPPER CORNER OF

>THE DIALOG BOX.

>BUT NOTHING IS DISPLAYED THERE.

>

>CAN SOMEONE HELP ME FIND OUT WHAT

>I'M DOING WRONG?

>

>



(1) Don't do this in OnPaint(). Moving a child in OnPaint will cause

another OnPaint(). You can reposition controls in OnInitDialog, or in

OnSize if the dialog is resizeable.

(2) temp_rect.right is uninitialized == garbage

(3) rect.left is 0 by definition. Why are you dividing this by 2 and

subtracting 5?

(4) No purpose is served by calling the GetClientRect API instead of the

member function. Ugly!



--

Scott McPhillips [VC++ MVP]







-