Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

picture control(ie., rectangle)

Posted on 2004-08-02
6
Medium Priority
?
1,319 Views
Last Modified: 2013-11-20
In MFC, I have a picture control(ie., rectangle). The video will be displayed there. Now, I want to change the resolution. I used the following code,

CWnd* pWnd = GetDlgItem( IDC_STATIC_PRE );
stat.SubclassDlgItem(IDC_STATIC_PRE, this);
stat.SetWindowPos(&CWnd::wndTop,1,1,40,40,SWP_DRAWFRAME|SWP_SHOWWINDOW);
CStatic stat;

But when I run the application, the static window(rectangle) disappears. Why?. What code I have to add to set the new window position?.
0
Comment
Question by:renetaprincy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 11693485
The code as posted above should not work. Do you meant:

CWnd* pWnd = GetDlgItem( IDC_STATIC_PRE ); // attention the return value can be temporary.
// stat.SubclassDlgItem(IDC_STATIC_PRE, this); // what is this needed for?
pWnd->SetWindowPos(&CWnd::wndTop,1,1,40,40,SWP_DRAWFRAME|SWP_SHOWWINDOW); // has no effect if pWnd is temporary.

But a more robust approach would be to use a control variable for that static frame. Open the class wizard and select the member variable tab. Here select the class and ID (IDC_STATIC_PRE) and create a variable. Here select as type control (not value). Now you cna use that member variable inside your functions to change the size and position.

m_csPre.SetWindowPos (...); // no need to find a window.
0
 
LVL 7

Accepted Solution

by:
vijay_visana earned 300 total points
ID: 11693510
Though it's not clear from your question what exacly your problem.

first line should be
CStatic* pWnd = (CStatic*)GetDlgItem( IDC_STATIC_PRE );

your declaring CStatic stat after you used it.

Please be specific about your problem and give code where you have doubt


vijay



0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11693528
CWnd* pWnd = GetDlgItem( IDC_STATIC_PRE );
stat.SubclassDlgItem(IDC_STATIC_PRE, this);
stat.SetWindowPos(&CWnd::wndTop,1,1,40,40,SWP_DRAWFRAME|SWP_SHOWWINDOW);
CStatic stat;

There are many strange things in your code:
- stat is defined (last line) AFTER using it. How this compiles?
- pWnd apparently points to your static control (first line), then, why do you apply SetWindowPos to stat intead of pWnd?
- Why do you subclass stat?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:renetaprincy
ID: 11700787
CStatic m_csPre;
m_csPre.SetWindowPos (&CWnd::wndTop,1,1,40,40,SWP_DRAWFRAME|SWP_SHOWWINDOW);

I have selected the class and ID (IDC_STATIC_PRE) and created a variable. There I have selected as type control. Then I have used in the function. But, when I run, there is an error. Why?.


0
 
LVL 13

Expert Comment

by:SteH
ID: 11701267
What is the error? And where do you use it first? The control variable can only be used in or after OnInitDialog (assuming a dialog based app).
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11704734
CStatic m_csPre;
// Where is the m_csPre.Create(.......) ?
m_csPre.SetWindowPos (&CWnd::wndTop,1,1,40,40,SWP_DRAWFRAME|SWP_SHOWWINDOW);

CStatic m_csPre must be a member of your dialog or view object, because If you instantiate (declare) it inside a function, it will be destroyed at returning from function.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question