Cstatic : get pos relative to parent

I need to know where my CStatic control is relative to its parent dialog.




0
biproc2004 (43)
1/11/2005 8:13:57 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
836 Views

Similar Articles

[PageSpeed] 6

Depends on where you want to know this from!?

From within the dialog
void CMyDialog::GetPos()
{
    m_Static.GetWindowPos(...);
    ScreenToClient(...);
}

AliR.

"Vince" <biproc2004@yahoo.fr> wrote in message
news:41e432f4$0$15681$626a14ce@news.free.fr...
> I need to know where my CStatic control is relative to its parent dialog.
>
>
>
>


0
AliR1 (391)
1/11/2005 8:43:45 PM
GetWindowPos doesn't exist in MFC but anyway
my problem is to get position of my CStatic derived control.
Since I am inside the control GetWindowRect doesn't work since it is not yet 
displayed.
So I suppose I have to get a message but which one ?

// CxStatic is a CStatic derived control
void CxStatic::DrawBitmap(CDC* pDCMem, CRect* pRect)
{
    ::GetWindowRect(...) // Doesn't work inside the control

}


"AliR" <AliR@newsgroup.nospam> a �crit dans le message de news: 
5UWEd.15897$iC4.6629@newssvr30.news.prodigy.com...
> Depends on where you want to know this from!?
>
> From within the dialog
> void CMyDialog::GetPos()
> {
>    m_Static.GetWindowPos(...);
>    ScreenToClient(...);
> }
>
> AliR.
>
> "Vince" <biproc2004@yahoo.fr> wrote in message
> news:41e432f4$0$15681$626a14ce@news.free.fr...
>> I need to know where my CStatic control is relative to its parent dialog.
>>
>>
>>
>>
>
> 


0
biproc2004 (43)
1/11/2005 10:25:56 PM
Vince wrote:

> GetWindowPos doesn't exist in MFC but anyway
> my problem is to get position of my CStatic derived control.
> Since I am inside the control GetWindowRect doesn't work since it is not yet 
> displayed.
> So I suppose I have to get a message but which one ?
> 
> // CxStatic is a CStatic derived control
> void CxStatic::DrawBitmap(CDC* pDCMem, CRect* pRect)
> {
>     ::GetWindowRect(...) // Doesn't work inside the control
> 
> }

GetWindowRect or GetClientRect will work from inside the control. 
Whether the control is displayed or not does not matter.  But if the 
control does not yet exist (i.e. does not have an m_hWnd) then nothing 
can work, and the position you are trying to get does not exist yet!

You can also use GetParent()->GetWindowRect so you can compute the 
difference in position between the dialog and the control.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
1/11/2005 11:20:43 PM
Sorry brain fart. I ment GetWindowRect. Why doesn't GetWindowRect work?
Make sure your window exists. m_hWnd is not NULL.

"Vince" <biproc2004@yahoo.fr> wrote in message
news:41e451e4$0$15696$626a14ce@news.free.fr...
> GetWindowPos doesn't exist in MFC but anyway
> my problem is to get position of my CStatic derived control.
> Since I am inside the control GetWindowRect doesn't work since it is not
yet
> displayed.
> So I suppose I have to get a message but which one ?
>
> // CxStatic is a CStatic derived control
> void CxStatic::DrawBitmap(CDC* pDCMem, CRect* pRect)
> {
>     ::GetWindowRect(...) // Doesn't work inside the control
>
> }
>
>
> "AliR" <AliR@newsgroup.nospam> a �crit dans le message de news:
> 5UWEd.15897$iC4.6629@newssvr30.news.prodigy.com...
> > Depends on where you want to know this from!?
> >
> > From within the dialog
> > void CMyDialog::GetPos()
> > {
> >    m_Static.GetWindowPos(...);
> >    ScreenToClient(...);
> > }
> >
> > AliR.
> >
> > "Vince" <biproc2004@yahoo.fr> wrote in message
> > news:41e432f4$0$15681$626a14ce@news.free.fr...
> >> I need to know where my CStatic control is relative to its parent
dialog.
> >>
> >>
> >>
> >>
> >
> >
>
>


0
AliR1 (391)
1/12/2005 3:04:02 PM
Reply:

Similar Artilces:

Account's Open Opportunities Also Get Re-Assigned
Is there a way to prevent open opportunities from being re-assigned after changing the account's owner? There is a constant account owner shuffle in my organization and it is tedious to rollback the opportunity re-assignment done automatically by re-assignment of accounts. We are using MS CRM v3.0 and at a minimum the system should ask the user whether he/she would like to also re-assign open opportunities. On May 17, 1:08=A0pm, Maleke Turat <MalekeTu...@discussions.microsoft.com> wrote: > Is there a way to prevent open opportunities from being re-assigned after > chang...

where do the windows class gets registered? #2
Hello all! I am learing windows programming and mfc. and getting confused terribly. Here is my latest confusion.:) We make our own class with the help of wndclass structure. and then register it with the help of RegisterClass function. Now my confusion is where do that class gets registered? In the windows own registry??? If yes can we find the entry of our own class in the windows registry? Hope I haven't asked a totally insane question :)? Regards, Yogesh P Joshi yogesh schrieb: > Hello all! > > I am learing windows programming and mfc. and getting confused terribly. >...

flickering free and transparent CStatic
Hi, I am currently trying to write a very simple CStatic derived control. It has to be flicker free and transparent. I mean by transparent that if there is a bitmap under the Cstatic we will see it. I have achieved to do a transparent CStatic but that flickers and one flicker free but not transparent. The problem is I am using the CMemDC (by Keith Rule available on code project) but as someone said the class is assuming the background is Opaque by filling in the background of the DC.(FillSolidRect(m_rect, pDC->GetBkColor());) But it should check the BK mode instead and do somethin...

I'm getting a large toolbox for email that I can't get rid of
I've tried everthing to get rid of this toolbox, but I just can't. It's only on one document, not all of them. Any ideas? Does this toolbox look a lot like email headers? If yes, try: File|Send to|Unselect Mail Recipient. (it's difficult to see that the icon is pushed in at first glance.) Sue wrote: > > I've tried everthing to get rid of this toolbox, but I > just can't. It's only on one document, not all of them. > Any ideas? -- Dave Peterson ec35720@msn.com ...

How do I get my data labels on a pivot chart to retain their form.
I have created a pivot chart as an objecct in another worksheet. The data labels are on the chart in a font larger than I want (Arial 19). I can click on each of the series, and reduce the font to Arial 10, but as soon as I refresh the chart, the font goes back up to Arial 19. The default font for my excel spreadsheet is Arial 10. Loss of formatting is a known problem with pivot charts. There's information in the following MSKB article, suggests recording a macro as you apply the formatting: XL2000: Changing a PivotChart Removes Series Formatting http://support.microsoft.co...

Function = get selected cell data
Hi all - I’m looking for a way to have data copy/load from one cell to another via selected cells. For example, I select cell a1; the data within in cell a1 is then copied/loaded into cell b1. So, I’m looking to add a formula to cell b1 that retrieves data from whichever cell is selected within the spreadsheet. Is this possible? Thanks Hi not possible with formulas. This would require vBA "Mike G - D.C." wrote: > Hi all - > I’m looking for a way to have data copy/load from one cell to another via > selected cells. For example, I select cell a1; the data within in ce...

Simple hack to get $500 to your home.
Simple hack to get $500 to your home at http://uslatest.tk Due to high security risks,i have hidden the cheque link in an image. in that website on left side below search box, click on image and enter your name and address where you want to receive your cheque.please dont tell to anyone. ...

Working with CStatic!
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; ...

when i select dont update I get #REF!
When I select dont update sheet, previous version should my figures. With 2k3 figure change to #REF! I'm puzzled, how do i prevent this from happening? xl2002+ likes to recalculate any workbooks that were created in previous versions. In earlier versions of excel, if you answer No to the update links prompt, the existing values are kept. In xl2002+, you get those errors. Jim Rech posted a registry tweak: http://groups.google.com/groups?threadm=uzkujhMHEHA.3284%40TK2MSFTNGP11.phx.gbl Maybe it'll work ok for you. mmollat wrote: > > When I select dont update sheet, previous...

How to get the reference to the cells of the current data group
Hi there, I have the data in my worksheet grouped such that I can show & hide a hierarchy by clicking the +/- icons on the very left side of the sheet. What I am looking for now is a simple and easy way to sum the numbers in on of the columns for each group. Of course, I can type a formulas like =SUBTOTAL(9, A5:A8) in each summary row (where A5:A8) is one of the subgroups. But with almost 100 subgroups which are also changing from time to time, this is quite tedious. What I am looking for is something like: =SUBTOTAL(9, CURRENTGROUP()) Where the ficticious function CURRENTGROUP()...

How To Get 1 Million Visitors Without Paying A Dime In Advertising
Hi, The following links is a must for all online businesses whether big or small. ( if you are serious about making money in the internet ) Essentially, all businesses needs marketing to get the all so important sales that brings you the revenue. To learn how to Get 1 miillion visitors to your site without paying a dime for your ads. ( forever ) Goto http://moneyhome.com/cgi-bin/i.pl?c=a&i=27202 To become an affiliate and earn endless residual income. Goto http://www.freeadguru.com/cgi-bin/i.pl?c=r&i=27202 best regrds, Rene --- MAF Anti-Spam ID: 20050420235059...

Getting blamed for lost folders
Just doing my job, I installed all available updates to Microsoft products. Now a co-worker is claiming I lost her extra mail folders in the process. There's always a problem with this person.... but is it possible this was caused by the update process? We are networked and do not use Exchange. The 'extra folders' are folders the user has set up in addition to Inbox, Sent, Outbox, etc., to store the hundreds of msgs. she thinks she has to have taking up space within the system. I simply, or maybe not so simply, need to know if the Microsoft updates will lose these fol...

Cant get help elsewhere
Hi I apologise in advance if this is not the place to put this. I have tried to get on to hotmail support and cant. For some reason hotmail, opening emails or even trying to get onto the forum is either slow (i.e. opening hotmail) or does not load at all, opening emails..does not open, or trying to get onto the forum, does not dl. Is something wrong with hotmail. other sites seem to open ok? Thanks for any help. Mel HOW TO Optimize IE for Windows Live Hotmail & windowslivehelp.com http://windowslivehelp.com/solution.aspx?solutionid=3c7c3338-369e-4220-b29d-71ce660fe...

How to get a programming job?
I know this is an awkward question but I am just stumped! I am presently a College student at Devry University Online. I am working towards my Bachelors in Computer Information Systems. I have a 4.0 GPA, Dean's List Award & President's List Award. I have already graduated from College America with my Associates Degree in Computer Programming, with similar achievements as those listed above and was a College America valedictorian. Yet none of that helps me because every programming job I run across on Dice & CareerBuilder require at least 1 year industry experience ...

How can I create subitem in my own CStatic?
Hello,All! I have wroten a programme which is a sub-class of CStatic, and I used the CDialog to create a CStatic,then I replaced it by my own sub-class, However,when I try to create an item in my sub-class in its member function which was called "afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);",this function wouldn't be called. is there anybody who can tell me how I can create an item in my own-subclass? Thanks in advance! OnCreate will get called when the item is created dynamically using the Create method. If you are using DDX_Control to attach the variable to the con...

how do i get labSET to work on microsoft excel?
I cant get labSET to work in my microsoft excel i think you may have to acctivate it in the program but i am not sure. if you do i don't know how to do it. What is labSET? Is it something you use for a class? "Easyq17" <Easyq17@discussions.microsoft.com> wrote in message news:D5657704-8950-4BAB-9BE7-4008BEAF3BE8@microsoft.com... >I cant get labSET to work in my microsoft excel i think you may have to > acctivate it in the program but i am not sure. if you do i don't know how > to > do it. ...

Getting MEDIAN and PERCENTILE to exclude #ERROR values
Is there a way to get PERCENTILE or MEDIAN to exclude error values? I give as an argument a range in which some of the values are #VALUE, but rest are valid, legal numeric values, and it is those remaining non-error values that i want MEDIAN or PERCENTILE of. Thank you. Try the following formulas, which need to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER... =MEDIAN(IF(ISNUMBER(A2:A100),A2:A100)) and =PERCENTILE(IF(ISNUMBER(A2:A100),A2:A100),0.8) Adjust the references and percentile value accordingly. Hope this helps! In article <UTqfg.2573$hv1.1679@trnddc01>, &...

ADO getting DATETIME type
I tried to get the DATETIME data type from SQL Server using ADO in VC++. The DATETIME value shown in SQLServer is 3/20/2008 2:00:00 AM But when I look at the vtValue object in VC++ debugger it looks something like: tagVARIANT DATE = 39527.083333333336 vt 7 unsigned short DATE 39527.083333333336 double How can I modify the following code to get the correct DATEIMTE? ========================= _variant_t vtValue; vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue(); FieldValue=vtValue.date; ========================= bool Table::Get(char* FieldName,int& FieldValue) ...

Get Paid for NOT Buying Stock #2
Make Money "Selling PUT Spreads" Easier and Safer Than You May Think! http://barryshore.com/subscribe.html "In A Nutshell" here's how you make money Selling Put Spreads with very little risk. Pick a stock you like (I'll show you how I do that). Then DON'T buy it now. Instead someone will actually pay you to buy that stock later for LESS money. Sounds weird, doesn't it? Nevertheless, it's true! Furthermore, you don't ever have to actually buy the stock. I'll also show you how to create a "spread" which will limit your losses. Check ou...

HOw to get the application directory
Excuse me.. this does sound like a stupid question. I need to get my application's directory path. I must not be searching on the right names GetApplicationPath()? thanks How about GetModuleFilename()? "Jona Vark" <noemail@all.com> wrote in message news:zHEye.747$6%2.453@newssvr21.news.prodigy.com... > Excuse me.. this does sound like a stupid question. I need to get my > application's directory path. I must not be searching on the right names > GetApplicationPath()? > > thanks > > GetModuleFileName() GetModuleHandle() "Jona Vark&q...

Email Getting stuck in the outbox
I have ONE end user getting emails stuck in his outbox, usually between the times of 4pm and 5pm only. He is running all the latest updates on the OS (XP) and on Office 2007. We are running Exchange 2007 with all the patches available to date as well. At first I looked at our exchange server to see if that is where the problem resided. I did some tweaking there, but nothing ever remotely cured this problem. So, I started to concentrate on his laptop. One of the first things I did was update all his contacts by creating a second contacts folder in outlook and copying all his...

CStatic
I have a CStatic in a dialog box which contains a graphic. I want to be able to clear what's in the CStatic if the user clicks a button. How do I set the CStatic to show nothing. I don't want to set it to null because I don't want to get rid of it. You can always do nothing in OnPaint except clearing the dc but an easier way would be to simply hide the control. Subclass it and then use ShowWindow to hide/show it. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "William Gower" <w_gower@hotmail.com> wrote in message news:e8b6g8jhDHA.2504@TK2MSFTNGP09.phx.gbl.....

zoom bitmap in CStatic Picture Control
Hello NG, I show an image with SetBitmap of my CStatic Picture Control in a dialog. My CStatic window's size is unsizable, so I let the image be shown centred. But each image is dimensioned differently. How can I zoom the image in my CStatic? CRect rect; m_stcPic.GetWindowRect(rect); // mein CStatic Picture Control double fx = (double)image.GetWidth() / (double)rect.Width(); double fy = (double)image.GetHeight() / (double)rect.Height(); HBITMAP m_bitmap = image.MakeBitmap(); if (fx > fy) { // use fx to zoom } else { // use fy to zoom } m_stcPic.SetBitmap(m_bitmap); In ...

Not getting notifications
Since Virgin Mail changed recently I'm not getting notifications from eg: facebook, tripadvisor etc . Does anyone know how to fix this please? What did Virgin Mail change? Did you get a new e-mail address? Did you then update your alert profile on Facebook, Tripadvisor, etc? Do you see notifications on Virgin Mail's Webmail page? If they are not there, there is nothing foe WinMail to download. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "diberry" <diberry@discussions.microsoft.com> wrote in message news:7C6174A5-3995...

Who could tell how to get the content in win2k?
Look: void CMovemouseDlg::OnMouseMove(UINT nFlags, CPoint point) { ClientToScreen(&point); CWnd* pWnd = CWnd::WindowFromPoint(point); if (pWnd) { HWND hwndCurr = pWnd->GetSafeHwnd(); char szText[255]; ::SendMessage(hwndCurr, WM_GETTEXT, 255, (LPARAM)szText); m_Edit= szText; UpdateData(false); } } CDialog::OnMouseMove(nFlags, point); } but when the edit's property is password,my program doesn't get the content,who could tell me how to solve? I'm not sure why you have to get GetSafeHwnd() or use ::SendMessage, or use a fixed-size 8-bit chara...