Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how to get the current screen width()

What I have tried:

i have tried with below
CRect rect;
GetClientRect(&rect)

int width = rect.width();
but its not working
Posted
Updated 16-Sep-20 1:22am
Comments
Mohibur Rashid 14-Apr-17 2:38am    
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx page explains what it is suppose to do. It does not work is not a very helpful message to the reader. Let us know what do you expect and what are you getting.
Member 13089825 14-Apr-17 2:47am    
i want to show on satus bar is the way line number i shown in th evisual studion status bar "LN n"
so for above requiremnet i am doing like below
CString status;
status+= "connected"
CRect rect;
GetClientRect(&rect)
for (inti=0;i<rect.width()-100);i++)
{
status+=" ";
}
status += "LN " and after thil LN i am appending the my current line number(or rownumber which is getting from list view whilcking clicking time)
(CMainFrame*)(AfxGetApp()->m_pMainWnd)->setMessagetext(status);
but here problem is its not showing corrctly while minimizing window its showing some place and maxmizing time its showing some place
could you please help me here how to show staus bar text on correct place while chnaging window width
Richard MacCutchan 14-Apr-17 4:38am    
You need to update these values on every WM_MOVE message.
Member 13089825 14-Apr-17 4:45am    
is it possible to add text from rightside on statndard staus bar using below one
(CMainFrame*)(AfxGetApp()->m_pMainWnd)->setMessagetext(string);
Richard MacCutchan 14-Apr-17 4:49am    
Yes, and I explained what you need to do in your previous question on the matter: Allign text from right side on status bar[^].

1 solution

What you need is the following code:

CWnd* pwndParent = this->GetParent();

CRect rc;
pwndParent->GetWindowRect(&rc);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900