Resizing dialog #2

Hi,
I have a dialog and it contains some controls like a listbox. The list
box borders should have about 20 pixles space from the dialog borders.
It is ok when the dialog is not resized, but when I resize the dialog
the, the list box stays in its position and the space on the right
size increases. How can I make my listbox strech when the dialog is
resized.
Thanks in advance.

0
4/1/2007 2:12:31 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
460 Views

Similar Articles

[PageSpeed] 57

"Shahoo" <shahookamangar@gmail.com> wrote in message 
news:1175436751.701375.302130@p77g2000hsh.googlegroups.com...
> Hi,
> I have a dialog and it contains some controls like a listbox. The list
> box borders should have about 20 pixles space from the dialog borders.
> It is ok when the dialog is not resized, but when I resize the dialog
> the, the list box stays in its position and the space on the right
> size increases. How can I make my listbox strech when the dialog is
> resized.

Override CMyDialog::OnSize() and call MoveWindow() for each control you want 
to resize.  Only do this if the control's HWND is not NULL (because OnSize() 
is first called before the child controls are created).  If you have lots of 
controls, use a layout manager (find using google) to avoid writing so much 
code.

-- David 


0
dc2983 (3206)
4/1/2007 2:15:34 PM
Shahoo a �crit :
> Hi,
> I have a dialog and it contains some controls like a listbox. The list
> box borders should have about 20 pixles space from the dialog borders.
> It is ok when the dialog is not resized, but when I resize the dialog
> the, the list box stays in its position and the space on the right
> size increases. How can I make my listbox strech when the dialog is
> resized.
> Thanks in advance.
> 


http://www.codeproject.com/dialog/resizabledialog.asp
http://www.codeproject.com/dialog/RPResizeDlg.asp
http://www.codeproject.com/dialog/ResizableLib.asp

or more simply you just need to handle WM_SIZE message (OnSize)
and resize your controls using SetWindowPos or MoveWindow.
0
richom.v (84)
4/1/2007 2:21:59 PM
Hi Shahoo,

Take a look at this library... it's very small, easy to implement, and gives 
you tons of flexibility without having to worry about the details.

http://www.codeproject.com/dialog/resizablelib.asp?df=100&forumid=2253&exp=0&select=1065624&tid=1065114

Tom

"Shahoo" <shahookamangar@gmail.com> wrote in message 
news:1175436751.701375.302130@p77g2000hsh.googlegroups.com...
> Hi,
> I have a dialog and it contains some controls like a listbox. The list
> box borders should have about 20 pixles space from the dialog borders.
> It is ok when the dialog is not resized, but when I resize the dialog
> the, the list box stays in its position and the space on the right
> size increases. How can I make my listbox strech when the dialog is
> resized.
> Thanks in advance.
> 

0
tom.nospam (3240)
4/1/2007 2:24:28 PM
Shahoo wrote:
> Hi,
> I have a dialog and it contains some controls like a listbox. The list
> box borders should have about 20 pixles space from the dialog borders.
> It is ok when the dialog is not resized, but when I resize the dialog
> the, the list box stays in its position and the space on the right
> size increases. How can I make my listbox strech when the dialog is
> resized.
> Thanks in advance.
> 

Add a message handler in the dialog for WM_SIZE and do this to resize 
the control when the dialog is resized...

void CxxDlg::OnSize(UINT nType, int cx, int cy)
{
   CDialog::OnSize(nType, cx, cy);
   // m_control is your CListBox control variable
   if (m_control.GetSafeHwnd())
   {  // resize child window
      m_control.MoveWindow(CRect(20,...,cx-20,...));
   }
}

-- 
Scott McPhillips [VC++ MVP]

0
Scott
4/1/2007 2:25:34 PM
Oops, sorry Vincent.  Didn't mean to give the same link as you did.  I was 
just plowing through.  I see you gave some other alternatives as well.

Tom

"Vincent RICHOMME" <richom.v@free.fr> wrote in message 
news:460fbf49$0$3210$426a34cc@news.free.fr...
> Shahoo a �crit :
>> Hi,
>> I have a dialog and it contains some controls like a listbox. The list
>> box borders should have about 20 pixles space from the dialog borders.
>> It is ok when the dialog is not resized, but when I resize the dialog
>> the, the list box stays in its position and the space on the right
>> size increases. How can I make my listbox strech when the dialog is
>> resized.
>> Thanks in advance.
>>
>
>
> http://www.codeproject.com/dialog/resizabledialog.asp
> http://www.codeproject.com/dialog/RPResizeDlg.asp
> http://www.codeproject.com/dialog/ResizableLib.asp
>
> or more simply you just need to handle WM_SIZE message (OnSize)
> and resize your controls using SetWindowPos or MoveWindow. 

0
tom.nospam (3240)
4/1/2007 2:25:43 PM
Show your code.

The simplest version is

    if(c_MyList.GetSafeHwnd() != NULL)
       { /* resize the listbox */
         CRect r;
         c_MyList.GetWindowRect(&r);
         ScreenToClient(&r);
         c_MyList.SetWindowPos(NULL, 0, 0, 
                                                      cx - 2 * r.left,
                                                       cy - r.top - r.left,
                                                     SWP_NOMOVE | SWP_NOZORDER);
      } /* resize the listbox */

this keeps the border the same the whole way around, equal to the left border spacing.
						joe

On 1 Apr 2007 07:12:31 -0700, "Shahoo" <shahookamangar@gmail.com> wrote:

>Hi,
>I have a dialog and it contains some controls like a listbox. The list
>box borders should have about 20 pixles space from the dialog borders.
>It is ok when the dialog is not resized, but when I resize the dialog
>the, the list box stays in its position and the space on the right
>size increases. How can I make my listbox strech when the dialog is
>resized.
>Thanks in advance.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
4/2/2007 2:42:46 AM
Reply:

Similar Artilces:

Access 2.0 to Access 97 09-07-04
I have a vb 3.0 application that accesses data in an Access 2.0 database. If I convert this database to Access 97 it no longer works saying unrecognizable database format. Is there some way I can access Access 97 databases from vb 3.0? Hi, Nikki. > Is there some way I can access Access 97 databases > from vb 3.0? You'll probably need to upgrade your VB compiler as well. VB 3.0 creates 16-bit applications, whereas Access 97 is 32-bit, so if your VB application is accessing database application objects in addition to accessing data, then you'll likely run into problems. Th...

Converting Crystal report from MSCRM 1.2
I have a client who has upgraded to V3.0 for CRM. They want to continue using Crystal for their reporting engine because they have 40 custom reports. Does anyone know how to easily accomplish this? I have created a new connection to the new CRM Views in SQL, but I can't seem to figure out how to easily replace all the fields that are currently in the report using the SSO connection to my new connection. Any help would be greatly appreciated. Thanks, Amy many of the services such as rpttosql.com say they will only convert so far. some even say they will only get the general lay...

CImageList for CListCtrl in a modeless dialog
Hello, i'm using an CImageList in a derived CListCtrl. In a modal dialog containing the CListCtrl everything works fine, the images get displaied. Using a modeless dialog the images/toolvar icons didn't get displaied correctly (only in release version, in debug versions it work fine). What's missing or wrong? Any hints are welcome! Cheers Andy --- Member variable of a derived CListCtrl class DLLEXPORT CListMaik : public CListCtrl { ..... private: CImageList m_cImageIcons; } Function Creating image list icons from toolbar IDR_LISTICONS void CListMaik::CreateListIcons(void...

inbox repair #2
vikash@rfl.co.za <anonymous@discussions.microsoft.com> wrote: <blank message> And the question is??? -- Brian Tillman ...

Excel 97 crashes #2
Hi I'm working with Windows XP and Excel 97. When I enter the menu command "tools -> options" Excel crashes immediately. I tried to solve this problem with the following run-commands, but it fails: ....\EXCEL.EXE" /unregserver ....\EXCEL.EXE" /regserver Any ideas how to get this work? Tom "Tom" <tstruebi@gmx.net> wrote in message news:umnSeNOXEHA.4032@TK2MSFTNGP11.phx.gbl... > I'm working with Windows XP and Excel 97. When I enter the menu command > "tools -> options" Excel crashes immediately. Hi Tom, See the follo...

Resize Forms in Access 2007
I thought I read somewhere that Access 2007 had a new function, or something, enabling you to have forms automatically resize to fit the screen resolution of the user. Is this correct, or am I wrong? If I am correct, how do you use this feature? Thanks, BobV On Aug 9, 8:41 am, "BobV" <rk...@earthlink.net> wrote: > I thought I read somewhere that Access 2007 had a new function, or > something, enabling you to have forms automatically resize to fit the screen > resolution of the user. Is this correct, or am I wrong? If I am correct, how > do you use this feature?...

Resize a document
Hello, I would like to resize a publisher document 8.5 x 11...to 7 x 9 without disrupting the layout. Any ideas? Hi Tina (anonymous@discussions.microsoft.com), in the Microsoft� newsgroups you posted: || Hello, I would like to resize a publisher document 8.5 x || 11...to 7 x 9 without disrupting the layout. Any ideas? The only options really are to: 1. Create a new publication with the sizes you prefer. 2. Change the page size of your publication, then select all objects on the page, group them, then resize as a group. Items such as text and text in tables will not resize properly. You w...

outlook 2000 #2
cuando hago dos click sobre un mensaje el outlook no respode y se cuelga ...

dates in excel #2
hi all need help with the date function this is the situation i use excel daily to create a report. as this report is printed out i just save changes made. except at the weekend when i also make backups so that my boss can send the report by email on monday mornings. in the report we use the NOW function to display the date. when we used to open the backups the date never used to change ie if saturdays backup was opened on monday morning it used to still display saturdays date. now for some reason the date is automatically updating. anybody know how to prevent this happening You probabl...

Passwords #2
I want users to have to put in a password when they open outlook. I have selected the check box on the outlook settings to have it prompt for a password. When it prompts for the password it wants to authenticate to the exchange server and not with active directory. Am I forgetting something? You can't authenticate to Exchange - Exchange doesn't have the capability to do so. You may see the Exchange server listed, but rest assured, the authentication is taking place with Active Directory. -- Ben Winzenz Exchange MVP "Tbaker" <Tbaker@discussions.microsoft.com&g...

Timesheet Problem #2
I am trying to populate a timesheet with dates depending on the start date in B2. If B2 is the 16th of the month of Sept, I don't want anything to show up on the calendar for the 31th (blank in other words). Here is the formula I am using, but not working. Help. TIA =IF(($B$2)="","31",IF(EOMONTH(B2,0)=TEXT(($B$2)+ROW()-14,"DDD dd"),"",TEXT(($B$2)+ROW()-14,"DDD dd"))) Greg Hi Greg, With seed date in cell $B$2 and using rows down to leave the 31st blank. But show all other dates no exceptions for weekends and holidays. EOMONTH is in ...

Solver Add-in #2
I have an Excel File (around 4.5 megs) with 28 sheets. using the Solver add-in on the NPV function subject to a few restricting criteria. Max iterations 100 Max Change 0.01 under the Tools --> Calculation menu. Now when I launch Excel for the first time, I can click Tools --> Solver and see the conditions et al. but exiting from the Solver once and then later on trying to reaccess it through the same Tools --> Solver the Solver dialog does not come up. I have to quit excel and restart it again to view the Solver dialog. What could be going wrong here? Any ideas/suggestions? No ...

refund check #2
I have multiple customers requesting that the Refund Checks module be able to create Manual Payment batches in Payables Management. Right now Refund Checks only creates Computer Check batches. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/B...

Header & Footer #2
I often get files from other users who do not maintain the headers footers properly. Is it possible that we adjust the Header and/or Footer for on worksheet and the Header and/or Footer is automaticcaly updated for al other worksheets in the same file. It would save a lot of time, sinc otherwise you have to go to all the worksheets and make the change manually. Thanks in advance. PS: Using Excel 200 -- Message posted from http://www.ExcelForum.com Hi Group the sheets first(right click on a sheet tab and choose"Select all sheets") Change the header in File Page Setup Ungroup t...

2 Formatting Questions
Date Fields: Can we, in the CRM forms, format dates to read into the “15 Aug 2005” format? This is possible in reports, but by default, the forms use only numbers for dates, but in any format. Currency: Any ideas of how to track multiple currencies in the same application - specifically USD and Canadian? I know a Microsoft CRM installation currently supports one language. But aside from using a picklist to specify "USD", "CAN", "MEX", or other I'm concerned about how their forecasting. -- Carroll Little Vis.align, LLC 610-692-3290 x3326 www.visalign.c...

Outlook 2007 adding contacts issue #2
Hello! I apologize in advance if this has been answered, but I couldn't find it anywhere... today I added contacts to outlook 2007...never had used it before on Vista ever...and closed out went to lunch... came back, I cannot add any new contacts. All options to add a greyed out... If I select file new.....adding contacts is there but greyed out... any ideas on what to change? Thanks! lori, Go to your contacts page and type CTRL + N. The new contact page will open. Or on your contacts page, click New on the button that appears just below the File menu item. Or on your contacts pa...

Outlook blocked access to the following potentially unsafe attachments #2
We have just upgraded to Office 2003 and a lot of attachments do not get sent. We receive this error message instead. This particular attachment is a url. Any advice, Thanks, Jackie You may find this page useful: http://www.slipstick.com/outlook/esecup.htm -- Aloha, -Ben- Ben M. Schorr, Outlook-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "jackie" <anonymous@discussions.microsoft.com> wrote in message news:018e01c3aae6$81a637e0$a40128...

Outlook Client on CRM 1.2 Server Box for Demos
Hi, Did a CRM 1.2 install on Windows 2003 Server and all is working well. I have been seeing things on this newsgroup that say I should be able to install the Outlook client as well on this machine although it is an unsupported configuration. This is for demo's only. I am running it under Virtual PC. I would like to not have to have 2 Virtual PC images running just to show the Outlook integration to CRM. When I try to install the Outlook client I get a message at the start saying that the Outlook client is already installed. It is not. Suggestions anyone? Alan ...

Quarter-End Payroll Reports #2
When trying to process quarter end payroll reports I am receiving and unhandle script exception: [Microsoft][ODBC SQL Server Driver][SQL Server] Could not find stored procedure 'SCSB.dbo.uprGetPension'. ...

PST PAssword Recovery #2
Dear All , How can i recover my PST file password in Outlook 2003. If any 3rd party tool is available please send me the link. Kishore Dear Kishore have a look on this sites: http://www.slipstick.com/problems/scanpst.asp http://www.lostpassword.com/outlook.htm http://www.mapilab.com/office/password_recovery/ Maybe it helps. -- Oliver Vukovics Share Outlook without Exchange: Public ShareFolder Synchronisation for Notebooks: Public SyncTool http://www.publicshareware.com "Brinesh Kishore" <bbk.news@gmail.com> schrieb im Newsbeitrag news:uNOCy5odHHA.5044@TK2MSFTNGP05.p...

Excel: how to merge data from 2 workbooks with 1 col. in common?
I've got two separate workbooks. Each workbook contains unique columns except for one, which is a "key" column, or an id field. Example: I have a client # column in both workbooks. In the first workbook, I also have first name and last name columns. In the second column, I have phone number and address columns. How do I merge the two workbooks into one so that for each client # I have their first name, last name, phone number, and address. Well, I think I'd start by getting all the data into one workbook. With both workbooks open, select the worksheet with the phone n...

VS2003
Hello, I have a dialog resource and have created CDialog and a CFormView classes for this dialog. If I right-click a control in my dialog I can create a variable for the control, but how do I specify which class the variable belongs to, ie. my CDialog or CFormView class? I don't see how I can tell the add variable class wizard to which class the variable should be added. I'm converting a Dialog based app to a doc-view type app and am experimenting with CFormView, which is why I have CFormView and CDialog classes referencing the same dialog resource. Thanks for any help. -R...

Charting Problem #2
I have a problem with charting a Dynamic chart. I goes ok to set up the dynamic function as a range. It also shows the correct series. The range is as follows: =OFFSET(Sheet3!$A$1;1;Sheet3!$P$2-1;COUNTA(INDIRECT("C"&Sheet3!$P$2;FALSE));1) Where P2 is an input from a listbox, and the name of the range is: Sheet3!Dato. When I try to change the reference for the series i get the following message: "Your formula contains an invalid external reference to a worksheet. Verify the path, workbook, and range name or cell reference are correct, and try again." The serie...

Data List #2
In relation to an earlier question, I am looking for a way of creatin box which displays the contents of a list, which when clicked on can b copied to a current cell, but other items added to this list. For example, in one spreadsheet a list of; John Paul Peter In another spreadsheet, a view of this, so that the values can easil be copied over, but also the abaility to add another name. Something like.. [Players] | John | | Paul | | Peter | ... [ADD NEW] Any ideas? Many thanks, Mic -- Message posted from http://www.ExcelForum.com Mich Lookup data validation. It is very straigh...

Multiple Users for office #2
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi, if I have office:2008 installed on my imac and I set up a new user (one of may staff has left and the new person is using the same machine) how do I get office to appear in the list of applications? I am hoping i dont have to reinstall given it is the same licence being used, just by a new person. All help much appreciated CSR > Hi, if I have office:2008 installed on my imac and I set up a new user (one of may staff has left and the new person is using the same machine) how do I get office to appear in the...