position of a CDialog window

Hi all,
I'm just a beginner in MFC programming, and I have a littel problem: I 
don't know how to set the position of a window created

here's my code:
==================================================================
	CDialogOpInCorso* pDialog;
	pDialog = new CDialogOpInCorso();
	//Check if new succeeded and we got a valid pointer to a dialog object
	if(pDialog != NULL)
	{
		BOOL ret = pDialog->Create( IDD_OPINCORSO, this );
		if(!ret)	//Create failed.
		{
			MessageBox("Error creating Dialog", TITOLO_ERRORE, MB_ICONERROR );
		}
		pDialog->m_strOpInCorsoMsg = "... ... ...";
		pDialog->... ...
		pDialog->ShowWindow(SW_SHOW);
	}
==================================================================

How can I center the window pointd by pDialog into the parent windows?

Thanks in advance,
andrea
0
montoz (4)
5/8/2007 10:59:32 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
686 Views

Similar Articles

[PageSpeed] 4

Hi,

CWnd::SetWindowPos.

See also below...


"OT" wrote:

> Hi all,
> I'm just a beginner in MFC programming, and I have a littel problem: I 
> don't know how to set the position of a window created
> 
> here's my code:
> ==================================================================
> 	CDialogOpInCorso* pDialog;
> 	pDialog = new CDialogOpInCorso();
> 	//Check if new succeeded and we got a valid pointer to a dialog object
> 	if(pDialog != NULL)
> 	{
>		BOOL ret = pDialog->Create( IDD_OPINCORSO, this );
> 		if(!ret)	//Create failed.
> 		{
> 			MessageBox("Error creating Dialog", TITOLO_ERRORE, MB_ICONERROR );
> 		}
> 		pDialog->m_strOpInCorsoMsg = "... ... ...";

Do not initialize CDialog members after CDialog::Create called. Do it just 
after the CDialog C++ object is created [in your case after the 'new' 
statement]. To make sure that CDialog's methods - OnInitDialog and 
DoDataExchange would be called after the initialization.

> 		pDialog->... ...
> 		pDialog->ShowWindow(SW_SHOW);
> 	}

 You could have your dialog with WS_VISIBLE style and thus skip the call to 
ShowWindow(SW_SHOW).


==================================================================
> 
> How can I center the window pointd by pDialog into the parent windows?

CWnd::CenterWindow




-- 
======
Arman
0
armancho_x1 (249)
5/8/2007 12:09:01 PM
Arman Sahakyan ha scritto:
> Hi,
[...]

thanks!
0
montoz (4)
5/8/2007 1:53:17 PM
OT,

You can also call CenterWindow() in your OnInitDialog() function if you just 
want the window in the middle of the screen.  It's a simple way to do it.

Tom

"OT" <montoz@iol.it> wrote in message news:f1prpe$3rn$1@tdi.cu.mi.it...
> Arman Sahakyan ha scritto:
>> Hi,
> [...]
>
> thanks! 

0
tom.nospam (3240)
5/8/2007 2:33:41 PM
Reply:

Similar Artilces:

Drawing in a CWnd or CDialog?
Hello, I need to draw some lines in both a created CWnd and a CDialog box. I used this test code: class MyDialog: public CDialog { ... }; BOOL MyDialog::OnInitDialog () { CDialog::OnInitDialog (); .... CClientDC dc(this); CDC dcMem; BOOL theAnswer = dcMem.CreateCompatibleDC(&dc); theAnswer = dc.TextOut ( 50, 50, CString ("Hello")); theAnswer = dcMem.TextOut ( 50, 50, CString ("Hello")); .... return TRUE; } I didn't get "Hello" display in the dialog box when I called it in another routine as follows: MyDia...

change horizontal header position in excel
Anyone know how to change the horizontal position of the HEADER or FOOTER in EXCEL???? I would greatly appreciate any help. Thank you for your time. pico Wrote: > Anyone know how to change the horizontal position of the HEADER o > FOOTER in > EXCEL???? I would greatly appreciate any help. Thank you for your time. Pico, Can't you go into View/Header-Footer and use the "Left-Center-Right" catagories? You could use spaces in front of your data to move back an forth. Dav -- Piranh ----------------------------------------------------------------------- Piranha's Profi...

How do I transfer all Windows Live Mail & file to my new XP machin
On the old WinXP machine, WLM runs well with familiar folders, accounts, messages, and contacts. I don't want to have to set up the folders and accounts and "export" and "import". How do i transfer all of this to my new WinXP machine? ...

Common Controls 6 and buddy windows
I suspect I have been committing a heinous crime. It's a bit of a story, but it may give someone a laugh. :-( I have been using a CStatic as a buddy window of a spin button, with a slight "enhancement" which was fine hitherto, but does not work in common controls 6. The standard way Microsoft designed it is The spin button sends a WM_GETTEXT to the static buddy window, extracts the number from the text, increments/decrements it, puts it in a string and sends WM_SETTEXT to the static which displays it. This is fine if you want to display n=1,2,3,4,5,6... But I want ...

Windows NT
will money work on windows NT 4.O? Which version of Money? -- Regards Bob Peel, Microsoft MVP - Money Hints/Tips http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny UK Wishes/Suggestions mnyukwsh@microsoft.com "Tony" <taxley@crothall.com> wrote in message news:019201c36d8e$1c4b0cd0$a401280a@phx.gbl... > will money work on windows NT 4.O? With Money 2003, NT and Win95 ceased to be supported. >-----Original Message----- >will money work on windows NT 4.O? >. > ...

Position Transfers with GP 10 SP3 HR Position Control?
Is there anyone out there using GP 10 SP3 HR Position Control who knows how to do Employee Transfers? I'm trying to define the proper workflow for transferring/promoting an employee from one position seat to another and I think that I may have been missing something because at the end, even though I set an end date, I see 2 assigned positions: the old one and the new one; this includes Employee Seats, Position History, Organization Explorer, etc. Here are my steps at a high level: 1. With the Employee ID to be transferred, open Position Seats (Cards >> Human Resources >>...

Windows Vista/Windows XP Application Load Failure
Hello, I seem to be having an issue with Visual Studio 2005 Professional on Windows Vista Ultimate. It seems to me that whenever I build an MFC application (which contains several DLLs and an exe), the application runs beautifully on Windows Vista (e.g. my development machine). However, when I attempt to run it on Windows XP I essentially get a failure to load DLL/Merge Module issue. Upon inspection of the event viewer on XP I see the following error as being logged: Dependent Assembly Microsoft.VC80.CRT could not be found and Last Error was The reference assembly is not installed o...

Windows Live Mail shutting itself down
After composing a rather long email this evening I had just clicked on "Send" when I got a message something to the effect that "Windows Live Mail has encountered a problem and must shut down." I lost the email as the entire WLM system shut down. I don't know if this is related but a few minutes earlier when I first opened WLM and tried to receive messages (sync) nothing happened. I had told the computer to "work offline" earlier in the evening but before going to WLM had unchecked that option. My internet explorer was already open. I went b...

Subtracting positive amts from negative and positive from positive
I have a problem with a spreadsheet that SOMETIMES would result in subtracting positive amounts from negative where I would want the result to show negative but only the difference between the negative and the positive. In other words, if B9 is negative and B31 is positive then I want the negative in B9 to be reduced by the positive in B31 and reflect a negative amount (ie. -900 minus +200 = -700) but sometimes the amount in B9 is positive and B31 is positive and so then I just want B31 subtracted from B9 to reflect a positive (i.e. +900 minus +200 = +700). I found another an...

Extending XmlDocument and associated classes to provide character positions.
OK here's is what I wish to do. I have an XML file that I want to read into an XmlDocument. I then want to be able to interrogate the XmlNodes to find both their start AND end character positions within the original file. So e.g. <tagA><tagB>sometext</tagB></tagA> ^ ^ ^ ^ ^ ^ 0 6 12 19 26 33 tagA: start=0, end=33 tagB: start=6, end=26 sometext: start=12, end=19 I have seen the LineInfo example within the .net docs, see: "Extending the DOM" ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconextendingdom.htm and ...

Right click mouse window activation disabling
I have a dialog based application which has two dialogs where secod dialo is a modeless dialog. When I Right click the mouse button on any one of the dialog that comes to foreground. I need to block this behaviour on Right click (i.e only on Left click dialog should get activated). How can i achieve this? I tried overriding Rbutton down/up and commenting the base class call but no effect. also i tried pretranslating and blocking Rbutoon messages but without any success. That is not message of windows's job. To make what you want, using Mouse Hooking (WH_MOUSE) -- WebSite : Realizat...

Windows installer and clip organizer
I just installed microsoft office 2007 standard and whenever I open clip organizer, then windows installer also opens. I am not able to cancel windows installer and i am not able to do anything with clip organizer. I have tryed reinstalling it but nothing i have done has worked. Any suggestions? thanks. The Organizer has its own detect and repair. Are you allowing the Organizer to connect to the Office site? What are your firewall settings? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "dabears" <dabears@discussio...

Pop-Up Window
This question concerns Outlook 2003 in the new mail screen. When you are in the TO: field and type the first letter of a person's name, a pop-up box appears with some selections of people you might want to send the e-mail to. I have four systems out of 30 that do not display this pop-up windows and I have looked in every corner of the program trying to find where this options is to enable. Any suggestions on why this feature is not working on these four computers. James von Arx <JAVA@AJAVAONLINE.COM> wrote: > This question concerns Outlook 2003 in the new mail screen. ...

CListCtrl: want to be able to select a row at any position along it's length in report-view
I've set up a basic CListCtrl in the dialog editor (with headings) and i've noticed that i can only select the items in the first column to select a particular row and that only the item in the first column is highlighted when selected. Most other software with a similar display (e.g. outlook express) actually allows a row to be selected by clicking anywhere on a particular row and also highlights the entire row when selected. Is there some kind of special "style" setting for this type of behaviour - has anyone else out there noticed/fixed this problem? Regards, Kar...

open excel files in different windows
I have multiple excel files. I want to have them all opened at the same time in different windows so I can alt-tab to each of them. I have checked Tools|Options|View Tab|Check Windows in task bar but I still cant alt tab over they open in the same button ont he taskbar. Is there a way of doing this? Try use Ctrl+Tab. ===== * ===== * ===== * ===== Daniel CHEN UDQServices@Gmail.com www.Geocities.com/UDQServices >Free Data Processing Add-in< ===== * ===== * ===== * ===== "Luciano Cunha" <LucianoCunha@discussions.microsoft.com> wrote in message news:402720E2-37C4-...

Windows Live Calendar 01-28-10
Is there a way I can send one URL and allow access to a family member for ALL five of my calendars as I see it in Windows Live? ...

Which one do I position?
I am displaying a formview object called CVendorView in a childFrame called CVendorCF. I display this on the screen and resize the childframe to fit the view. I would like to place my different views in various spots on the desktop when the user clicks on the appropriate menu item. Which one do I move or set a position for the childframe or the formview? William Gower wrote: > I am displaying a formview object called CVendorView in a childFrame called > CVendorCF. I display this on the screen and resize the childframe to fit > the view. I would like to place my different views...

Setting Up Windows Mail
How do I set up Windows Email? The wizard asks for a POP3 or a SIIS or something else. What do I do? You call your ISP or e-mail server. Ask them for an e-mail address and the account settings. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Brad Davis" <braddavis01@microsoft.com> wrote in message news:%23WPSLUbiKHA.6096@TK2MSFTNGP02.phx.gbl... > How do I set up Windows Email? The wizard asks for a POP3 or a SIIS or > something else. > What do I do? > "Brad Davis" <braddavis01@microsoft.com&g...

Axapta Positions! CRM Positions!
Hello Everyone, I thought to get in touch with you all in regards tomy Axapta Positions We now have several Permanent and Contract positions available throughout the United States that require NO relocation. We are looking for the following candidates: Axapta Developers/Programmers, Systems Administrators, Project Managers, Functional Consultants with experience in the following modules: Trade and Logistics, Financials, Production, Manufacturing/Warehouse Management, etc. Our Contract positions require 70 percent travel and also allow for remote work. Contract length can start at 3 or 6...

Displaying Window Icons in Listbox.
i want to display local files and directories in a list box in my program. i am able to retrieve tht but i want to display respective icons against the file name. File extensions can be retrieved using GetExtension in mfc. i want to display the icons using Windows, NOT create my own bitmaps. kindly suggest how to go about it. Send this message WM_GETICON,Use SendMessageTimeout <nemesia31@gmail.com> wrote in message news:1161063177.331791.48490@h48g2000cwc.googlegroups.com... >i want to display local files and directories in a list box in my > program. i am able to retrieve tht b...

DSGET not working on Windows 7!!
Hello. I installed the Windows 7 AdminPak and everything seems to work great (all the MSC plug-ins). the DSQuery command-line tool works great as well. But... surprisingly and weirdly, DSGET does not seem to be working!! When I do something like... DSQUERY computer ou=whatever,dc=company,dc=com ....I get all computers. But when I do... DSQUERY computer ou=whatever,dc=company,dc=com | DSGET computer -samid ....Nothing happens!! Just back to a prompt instead of listing all the SAMs. Any ideas? I copied the DS commands out of the windows\winsxs directory (not sure why they ...

Adding more titles for Customer Maintenance window
I am looking for a way to add 'Rev.' as an option for the 'title' portion of the customers name. I see the table ASIAV210 is where they are stored, but after looking might be more than just addind a row manually. Can you provide more detail? What are you trying to accomplish? What is "Rev."? What "title" portion of the customer name are you referring to? -- Best regards, -- MG.- Mariano Gomez, MIS, MCP, PMP Maximum Global Business, LLC http://www.maximumglobalbusiness.com "RKMcC" wrote: > I am looking for a way to add 'Rev.' as...

Windows XP logon is taking too much time
Windows XP is taking too much time to logon to the desktop after I logon. In the past it appears to be linked to some network issues, like DNS etc. Is there some way to diagnose the issue? "How to perform advanced clean-boot troubleshooting in Windows XP" http://support.microsoft.com/kb/316434 --- Leonard Grey Errare humanum est vfclists wrote: > Windows XP is taking too much time to logon to the desktop after I > logon. > > In the past it appears to be linked to some network issues, like DNS > etc. > > Is there some way to diagnose the ...

Re: new newsgroupes and how to acctivate my windows mail account
"martin" <spaceman1466@google.com> wrote in message news:... > ...

Cursor position?
I would like that when I open workbook, cursor and view appears from first cell (A1). I have put in workbook open event Range("A1").Select , but workbooks open in the middle (vertical) of worksheet, depending where is cursor when I exit workbook. I hope I explained well, I want that I can see cell A1 when I open workbook, and that workbook doesn't open in middle of worksheet. If someone can help? Thank you Marc, Try this - add the macro to the ThisWorkbook module of your workbook. Save the workbook, close it and reopen it. All sheets should open up to cell A1. Private...