create a CStatic dynamically and move it

 Hello,

I would like to be able to create a CStatic object, to put it on a CDialog 
and to move it.
But I have no idea how to do this.


0
biproc2004 (43)
12/11/2004 3:38:12 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
432 Views

Similar Articles

[PageSpeed] 17

"Vince" <biproc2004@yahoo.fr> wrote in message
news:41bb141f$0$22304$626a14ce@news.free.fr...
> Hello,
>
> I would like to be able to create a CStatic object, to put it on a CDialog
> and to move it.
> But I have no idea how to do this.

Make it a member of the CDialog, call its Create and MoveWindow functions
during the lifetime of the dialog's HWND.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
12/11/2004 4:14:47 PM
Jeff Partch [MVP] wrote:

> "Vince" <biproc2004@yahoo.fr> wrote in message
> news:41bb141f$0$22304$626a14ce@news.free.fr...
> 
>>Hello,
>>
>>I would like to be able to create a CStatic object, to put it on a CDialog
>>and to move it.
>>But I have no idea how to do this.
> 
> 
> Make it a member of the CDialog, call its Create and MoveWindow functions
> during the lifetime of the dialog's HWND.

Hi Jeff,

I'm trying to do somthing similar. I declare and array of buttons in the 
dialog and then try to crate them in runtime. The buttons do not appear. 
  Here is the code:

void SelectChannelsDialog::MakeButtons()
{
	int i,j,dy, dx, ledge, tedge;
	CDC *dc;
	CRect rect;
	CString s;

	dy = rect.Height() * 0.75 / 5;
	dx = rect.Width() * 0.75 / 4;

	GetClientRect(rect);
	for(i=0; i<4; i++)
		for(j=0;j<5; j++);
		{
			s.Format("%i",i*4 +j);
			bt[i*4 +j].Create(	s, BS_CHECKBOX | WS_CHILD |WS_VISIBLE,
								CRect(ledge + i * dx, tedge + j * dy, dx/2, dy/2 ), this, NULL);
			bt[i*4 +j].ShowWindow(SW_SHOW);
		}

}

Any ideas?

Muz
0
me5944 (4)
12/20/2004 5:59:16 AM
"me" <me@there.net> wrote in message news:41C66A34.4040202@there.net...
> Jeff Partch [MVP] wrote:
>
> > "Vince" <biproc2004@yahoo.fr> wrote in message
> > news:41bb141f$0$22304$626a14ce@news.free.fr...
> >
> >>Hello,
> >>
> >>I would like to be able to create a CStatic object, to put it on a
CDialog
> >>and to move it.
> >>But I have no idea how to do this.
> >
> >
> > Make it a member of the CDialog, call its Create and MoveWindow
functions
> > during the lifetime of the dialog's HWND.
>
> Hi Jeff,
>
> I'm trying to do somthing similar. I declare and array of buttons in the
> dialog and then try to crate them in runtime. The buttons do not appear.
>   Here is the code:
>
> void SelectChannelsDialog::MakeButtons()
> {
> int i,j,dy, dx, ledge, tedge;
> CDC *dc;
> CRect rect;
> CString s;
>
> dy = rect.Height() * 0.75 / 5;
> dx = rect.Width() * 0.75 / 4;
>
> GetClientRect(rect);
> for(i=0; i<4; i++)
> for(j=0;j<5; j++);
> {
> s.Format("%i",i*4 +j);
> bt[i*4 +j].Create( s, BS_CHECKBOX | WS_CHILD |WS_VISIBLE,
> CRect(ledge + i * dx, tedge + j * dy, dx/2, dy/2 ), this, NULL);
> bt[i*4 +j].ShowWindow(SW_SHOW);
> }
>
> }
>
> Any ideas?
>
> Muz
Here's a few in advance of Jeff:
move GetClientRect to before first use (before the dy = line);
take the semicolon off the end of the second for statement of you'll do
nothing with it;
put something into ledge and tedge  before use;
since you are creating 5 buttons per outer loop count, use i*5 instead of
i*4 or you'll crash;
you don't need showwindow as you already said WS_VISIBLE; and
you'll need to fix the code in the CRect position used in create to move the
right and bottom as well as the left and top else you'll not see most of
them at all.

Presumably you have declared bt as a member variable array of 20 CButton

Do those things and you'll see some checkboxes on your dialog...

hth,
Johnny.



0
12/20/2004 8:30:19 AM
Johnny wrote:
> "me" <me@there.net> wrote in message news:41C66A34.4040202@there.net...
> 
>>Jeff Partch [MVP] wrote:
>>
>>
>>>"Vince" <biproc2004@yahoo.fr> wrote in message
>>>news:41bb141f$0$22304$626a14ce@news.free.fr...
>>>
>>>
>>>>Hello,
>>>>
>>>>I would like to be able to create a CStatic object, to put it on a
> 
> CDialog
> 
>>>>and to move it.
>>>>But I have no idea how to do this.
>>>
>>>
>>>Make it a member of the CDialog, call its Create and MoveWindow
> 
> functions
> 
>>>during the lifetime of the dialog's HWND.
>>
>>Hi Jeff,
>>
>>I'm trying to do somthing similar. I declare and array of buttons in the
>>dialog and then try to crate them in runtime. The buttons do not appear.
>>  Here is the code:
>>
>>void SelectChannelsDialog::MakeButtons()
>>{
>>int i,j,dy, dx, ledge, tedge;
>>CDC *dc;
>>CRect rect;
>>CString s;
>>
>>dy = rect.Height() * 0.75 / 5;
>>dx = rect.Width() * 0.75 / 4;
>>
>>GetClientRect(rect);
>>for(i=0; i<4; i++)
>>for(j=0;j<5; j++);
>>{
>>s.Format("%i",i*4 +j);
>>bt[i*4 +j].Create( s, BS_CHECKBOX | WS_CHILD |WS_VISIBLE,
>>CRect(ledge + i * dx, tedge + j * dy, dx/2, dy/2 ), this, NULL);
>>bt[i*4 +j].ShowWindow(SW_SHOW);
>>}
>>
>>}
>>
>>Any ideas?
>>
>>Muz
> 
> Here's a few in advance of Jeff:
> move GetClientRect to before first use (before the dy = line);
> take the semicolon off the end of the second for statement of you'll do
> nothing with it;
> put something into ledge and tedge  before use;
> since you are creating 5 buttons per outer loop count, use i*5 instead of
> i*4 or you'll crash;
> you don't need showwindow as you already said WS_VISIBLE; and
> you'll need to fix the code in the CRect position used in create to move the
> right and bottom as well as the left and top else you'll not see most of
> them at all.
> 
> Presumably you have declared bt as a member variable array of 20 CButton
> 
> Do those things and you'll see some checkboxes on your dialog...
> 
> hth,
> Johnny.
> 
> 
> 
Johnny,

Thanks. I guess I was tried.
Here is the fixed code:

void SelectChannelsDialog::MakeButtons()
{
	int i,j,dy, dx, ledge, tedge;
	int l,t,r,b, n;
	CRect rect;
	CString s;

	GetClientRect(rect);
	dy = rect.Height() * 0.70 / 7;
	dx = rect.Width() * 0.8 / 6;
	tedge =  rect.Height() * 0.15;
	ledge =  rect.Width() * 0.1;

	for(i=0; i<6; i++)
		for(j=0;j<7; j++)
		{
			n = i*6 +j+i;

			s.Format("%i",n+1);
			l = ledge + i * dx;
			t = tedge + j * dy;
			r = l + dx/2;
			b = t + dy/2;

			bt[n].Create(s, BS_CHECKBOX | WS_CHILD |WS_VISIBLE,CRect(l,t, r,b), 
this, NULL);
		}

}

It display all 42 buttons.

Muz
0
me5944 (4)
12/21/2004 3:35:48 AM
Reply:

Similar Artilces:

Can I use named range in data range box when creating pie chart?
I have 75 pie charts to create today. Is there a way to use named ranges in the data range box to speed this up? Yes. Just type in the name. -- George Nicholson Remove 'Junk' from return address. "BJackson" <BJackson@discussions.microsoft.com> wrote in message news:0DE9A0AD-C3BA-4242-B3BA-3CC3F0D87894@microsoft.com... >I have 75 pie charts to create today. Is there a way to use named ranges >in > the data range box to speed this up? Thank you! I was making it too difficult, thinking I needed to include the Sheet name along with the name range. ...

Assign Doc # When Creating SOP Returns
It would be nice to assign the document number when creating SOP returns rather than the system trying to assign the next number. ---------------- 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/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.msp...

Create an identical Chart Worksheet in Excel 2003
Hi: I used the F11 key to create a chart, which inserts just a chart as a new worksheet and gives it a default name, such as chart 2. My question is, can I create an identical chart as a new worksheet. This wouldn't be a copy, rather, a duplicate that is pulling information from the same location in the entire workbook. The reason I want to do this is because I currently have data for 12 different series, and each series has 7 values. What I would like to do is keep the same chart, but reduce the number of values per series from 7 to just 4. The easiest way seems to me to be to create ...

How do I apply a template I created to an existing publication?
I want to change a publication I created to a design that I created and saved in a publisher format. I do not want to have to recreate the publication in the new format, just change it! "Publication Options" "Apply Template" brings up a list of templates that does not include the one I created and want to use. Help! Did you save the publication as a template? Save as "Publisher template". What version Publisher are you using? If you are using 2007 you will have to browse to the templates. They are in a folder similar to this (Vista) These folders are hi...

Does anyone create sites without using tables for layout?
I know that a trend is to create websites that are pure css, and don't rely on tables for layout. Are asp.net devs taking that approach also? I checked a couple of major asp.net websites like newegg.com and they do seem to use tables for layout. Any info out there focused on table-less asp.net dev? Most of us try but I think our dirty little secret is most also cop out and start using tables here and there when their pages become increasingly complex. You'll note most of the "pure" CSS sites are often little more than what we call StackPanels in XAML using CS...

More on "Data Range"
This is wonderful for using "OFFSET" for a Dynamic Range Name for a Chart "Data Range"...http://processtrends.com/pg_dynamic_charts.htm Thank you again Kelly O'Day. It includes, for the X-Axis Dynamic Range Name... "Refers to:" ---> =OFFSET(dyn_ranges!$A$2,0,0,COUNTA(dyn_ranges!$A$A)-1) Currently, I'm using Column A to receive several Ranges for Charts from Access Automation. The...COUNTA(dyn_ranges!$A$A) will Count Entries in Column A from Cell $A$2 down. Other than separating the Ranges...IE.. For Chart 1...Columns A:B ---> COUNTA(dyn_ranges!$...

Moving Public Folders from Exchange Server 5.5 to Exc. Ser. 2003.
How can I move public folders from an Exchange Server 5.5 to a new Exchange Server 2003, which on a separate private network without connecting bother server on the same network? rekaman@gmail.com wrote in news:1144768961.479044.323920 @t31g2000cwb.googlegroups.com: > How can I move public folders from an Exchange Server 5.5 to a new > Exchange Server 2003, which on a separate private network without > connecting bother server on the same network? Export them to PST? Regards, -- R. Arlo Clizer FAQ: http://www.exchangefaq.org Archives: http://groups.google.com Thank you very mu...

How to create an order with products using workflow
It appears that using Workflow we can create a new Order record, but there does not appear to be any way to add Products to that Order once it has been created. Does anyone know how to do this? Hi, This will require custom development. -- uMar Khan :: MS CRM MVP CRM Freelance Consultant Email :: imumar at gmail dot com Blog :: http://umarkhan.wordpress.com MVP :: https://mvp.support.microsoft.com/default.aspx/profile/umar.khan "Bevan Edwards" wrote: > It appears that using Workflow we can create a new Order record, but there > does not appear to be any way to add Prod...

Create unique list from duplicates
The solution for this is probably a quite simple array formula wit COUNTIF, but I cannot seem to get it exactly right. All I want to d is take a list with many duplicates and list each duplicate once, in separate list, without modifying the first list. For example: Column 1 1 2 8 5 9 8 5 4 8 would generate: Column 2 1 2 8 5 9 4 Thanks in advance, Stephani -- Message posted from http://www.ExcelForum.com Hi Stephanie, What you are looking for, I believe, is Data > Filter > Advanced Filter. Select "Copy to another location" then click the "Unique records only&qu...

pictures move with text?
I have a 138 page document with lots of pictures inserted. If I resize the pictures, how do I make subsequent pictures move when the text moves? A small child turns to Ed, and exclaims: "Look! Look! A post from Rosie Flannigan <anonymous@discussions.microsoft.com>!"... > I have a 138 page document with lots of pictures inserted. > If I resize the pictures, how do I make subsequent > pictures move when the text moves? You will need to make the pictures inline Right-click > Format Picture > Layout > Object Position = Inline -- Ed Bennett - MVP Microsoft Pub...

how to create a clustered, 100% stacked combination chart
I want to create a chart with 2 100% stacked columns to compare % of 2 different years. Hi, Maybe you can use the information here but using 100% stacked columns. http://peltiertech.com/Excel/ChartsHowTo/ClusterStack.html Cheers Andy Keri in Vermont wrote: > I want to create a chart with 2 100% stacked columns to compare % of 2 > different years. -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info ...

Outlook 2003 (Creating new email)
I have been creating new email for several months now using Outlook 2003. While I was creating some new rules for emails, I must have changed a setting. Now when I attempt to create a new email, it pulls up a template with wierd fonts, some of my typing doesn't show up on my screen as I am inputting, my signature I had created doesn't show up, and it has a different feel than the before? Any idea what I have done and what I should do to restore my previous settings? ...

adjusable columns in original dynamics windows
adjusable columns in original dynamics windows, that you can sort on and size properly. Is there a way to post a screenshot to show you what i'm on about ?? ---------------- 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/Businesssolutions/Community/NewsGr...

Creating custom fields in shema manager
Hey, I am pretty new to MS CRM and I am trying to add a field to the pricelist. I have been looking at the schema manager, but I am unable to add a field. When I right-click on on the attributes, I choose 'New', but 'Schema field' is greyed-out, so I can't click on that. Somebody knows what wrong or how I can fix that ? Something I forgot ? Any help would be appreciated. thx BB ...

How to I create a tax export that is eariler than last year.
For example itss 2009, when I try to create a tax export report (.txf) I'm only given options for 2008 or 2009 (partial). How do I create a tax export for 2007? In microsoft.public.money, bmwbiker wrote: >For example itss 2009, when I try to create a tax export report (.txf) I'm >only given options for 2008 or 2009 (partial). How do I create a tax export >for 2007? Try closing Money, and setting your computer clock back to a date in 2008. You may have to disconnect from the internet, but probably not. Start Money again, and generate your .txf file. ...

Macro Creating
I have tried and tried to create a MACRO in Excel that will will delete a row. I have read several other marcos but have been unable to translate them to what I want to do. Listed below a sample of the type data I am talking about. What I want to do is have the macro read the second number in the colum and everytime it read a 0 it deletes that whole line of information. This type table will have some blank row but I do not want to delete. Can anyone help. Thanks in advance. Ron D60801 0 0 0 0 0 D78555 0 0 0 0 0 E98103 0 0 0 0 0 N04456 0 0 0 0 0 N05482 3 60 0 0 0 N95862 0 0 0 0 0 N96248 3 ...

Creating a Distribution List in OUTLOOK 2007
Hello, Is there a way to create a DISTRIBUTION LIST in OUTLOOK 2007 that contains contacts with a specific feature WITHOUT adding members one by one? E.g., I need a distribution list of all contacts whose e-mail address is in a particular domain. The following sequence DOES NOT work: CONTACTS ---> ACTIONS ---> NEW DISTRIBUTION LIST ---> SELECT MEMBERS ----> SEARCH (MORE COLUMNS) When I entered the domain name in the search window, I got no results. Thus, OUTLOOK did not search the entries of the e-mail addresses. Thank you for your help. ATK "...

how can I save a publisher created logo in picture format?
I've created a logo in MS Publisher. How can I save the logo in picture format so that it can be inserted into other programs? GEL <GEL@discussions.microsoft.com> was very recently heard to utter: > I've created a logo in MS Publisher. How can I save the logo in > picture format so that it can be inserted into other programs? What version of Publisher are you using? -- Ed Bennett - MVP Microsoft Publisher "Ed Bennett" wrote: > GEL <GEL@discussions.microsoft.com> was very recently heard to utter: > > I've created a logo in MS Publ...

Moving Down a List Within a Macro
In the following macro I repeat the same section about 50 times and it would be convient to put this into a loop. However each time the statement completes it uses a new paramter in the next section that i've definined at the top of the VBA statement (seen below as sheet01, sheet02). Is there anyway to move down this list in my statment using a loop so that it automatically selects the appropriate row in my list each time? Sub Macro1() ' ' book = Range("B10") booknum = 1 Path = Range("B11") Sheets("data").Select Heading = Range("A1:L1") ...

i need to create a chart from data from one workbook in another wo
hi new to excell so please be kind. i need to create a series of charts from different sets of data in one workbook, and have the charts show in another seperate workbook, and update automaticly when the data changes in the first workbook. i know how to create charts, its just that i can't get it linking from one workbook to another please help Mark Hi, An easy approach would be: Make the charts in the workbook containing the data. Cut and paste those charts into a new workbook. The charts are still linked to the original workbook. If you make changes in the data, the charts...

Create value list from a range of values
I've got a range of cells containing state abbrev. that I want to lis in another range excluding all duplicated states abbrev's. Is there a way to list the non-duplicated values automatically with function? I've tried using the excel Data Filter menu but it seems that needs t be performed manually. I need a function that automatically calculate when there is a change or addition to my list of states. Thanks for your help.. -- mallets12 ----------------------------------------------------------------------- mallets123's Profile: http://www.excelforum.com/member.php?action=...

How to create a Pivot table from text file with more than 65000 rows?
Is there a way to create a pivot tabel where the source data is a tex file with more than 65000 rows of data? Normnally I just import th text file to excel and then create a pivot, but in this case I have to many rows but don't want to lose data. I guess I can use the create pivot tabel from external data sourc function but could somone take me through the steps to do this from large text file - if this is possible! Many Thanks -- morchar ----------------------------------------------------------------------- morchard's Profile: http://www.excelforum.com/member.php?action=getinf...

Login time to Dynamics GP
We upgrade dot Dynamics GP and now the login time for several users is very long. It is taking most users several seconds, 3-10 to log in. For some others it is taking minutes to get into the system for them to be able to work. I have not found anyhting on Customer Source and have not heard back from Microsoft yet. Does anyone have any ideas? We are connecting to GP via citirx connections on a windows 2003 box. Thanks, ConfusedAdmin Backup Dynamics database (to be safe) Delete from dynamics..SY07110 Login as admin and you will see good speed again. I must do this every month t...

can't move pagebreaks
I am hoping someone can help me with my problem. Recently my Excel starting acting funny. When in page break view I cannot move the page break with my cursor. Also, when I am wanting to edit the range of cells in a formula. I normally click on the first cell referenced in the formula bar and a blue box will highlight the selected cells on the worksheet. I will then use my mouse to drag and resize the box around the appropriate cells that I am wanting in the range in the formula. Now I can no longer do that. I would appreciate any help anyone can give! Jayphx Tools|Options|Edit tab Che...

Combine Data from 2 spreadsheets to create a single Pivot Table
Hello From Steved I have 2 spreadsheets one is Called Auckland and the 2nd is Called Wellington. My Objective please is to use the data from 2 spreadsheets to create a single Pivot Table. Yes this is one workbook with 2 spreadsheets. is this possible. Thankyou. A person named Fazza shows how on Mr Excel: http://www.mrexcel.com/forum/showpost.php?p=1550658&postcount=3 I thought this was really cool, and now I'm incorporating it into a couple projects. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://Peltier...