|
Use GetSystemMetrics() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
You can also use ::GetDesktopWindow() to get the handle of the desktop and then ::GetWindowRect() to get the size of the desktop.
Danny
|
|
|
|
|
If you want the width and height of the desktop, use
CRect rectDesktop;<br />
<br />
SystemParametersInfo(SPI_GETWORKAREA, 0, &rectDesktop, 0);
This gets you the usable area (excluding the taskbar)
|
|
|
|
|
Amarelia wrote:
I want to get the screen height and width at run time, so that I can maximize my form size.
You don't need to know the dimensions of the desktop in order to maximize your main window. Just post it a WM_SYSCOMMAND message with a wParam of SC_MAXIMIZE .
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Amarelia wrote:
I want to get the screen height and widht at run time, so that I can maximize my form size.
In Continuation With Mr Ravi,
You can also use Api ShowWindow(SW_MAXIMIZE) ;
Amarelia wrote:
Is there any function or any idea how to get screen width and scree height at given resolution ?
In Continuation With All Above Reply:-
CRect lpRect;
GetWindowRect(::GetDesktopWindow(),&lpRect);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I work in a project with 4 other people. We use Visual C++ DevStudio 6.0 and SourceSafe. I have a question about resource files.
If I edit a dialog in the resource editor, and check it in, MSDev changes the font line in the resource to say
FONT 8, "MS Sans Serif" .
But if someone else changes it and checks it in, MSDev changes it to say
FONT 8, "MS Sans Serif", 0, 0, 0x1 .
Does anyone know what this ", 0, 0, 0x1" thing is all about? Is it something I can turn off, because with a large number of dialogs in the same resource file, doing a diff is quite laborious.
Here is an example of a dialog, before and after:
<br />
IDD_OPTIONS_EDITOR DIALOGEX 0, 0, 307, 255<br />
STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU<br />
EXSTYLE WS_EX_CONTEXTHELP | WS_EX_APPWINDOW<br />
CAPTION "Editor"<br />
FONT 8, "MS Sans Serif"<br />
BEGIN<br />
...<br />
<br />
IDD_OPTIONS_EDITOR DIALOGEX 0, 0, 307, 255<br />
STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU<br />
EXSTYLE WS_EX_CONTEXTHELP | WS_EX_APPWINDOW<br />
CAPTION "Editor"<br />
FONT 8, "MS Sans Serif", 0, 0, 0x1<br />
BEGIN<br />
...<br />
Thanks
d3m0n
|
|
|
|
|
[d3m0n] wrote:
FONT 8, "MS Sans Serif", 0, 0, 0x1.
The format is:
FONT pointsize, typeface, weight, italic, charset
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
The format is:
FONT pointsize, typeface, weight, italic, charset
David
Thanks for that, but please tell me where you found this information so I can find out why it keeps changing.
I tested it some more and it looks like whenever I modify a dialog, MSDev seems to scan the entire .rc file and adds the ", 0, 0, 0x1" string on some dialogs, and removes the string from others. Regardless of whether I modified (or even opened) those dialogs.
Maybe I should write a small exe to rip out all the ", 0, 0, 0x1" strings, and run that before every checkin. Seems like overkill though...
HELP!
Cheers
d3m0n
|
|
|
|
|
[d3m0n] wrote:
...please tell me where you found this information...
See here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi
how can i look for a file if it exists without using fopen
/\|-||\/|/\|)
|
|
|
|
|
here's a function that I put in one of my programs to make sure a folder existed, but you could also use it for a file.
BOOL FolderExists(CString strFolderName)
{
return GetFileAttributes(strFolderName) != INVALID_FILE_ATTRIBUTES;
}
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
|
Try this:
bool fileExists(LPCTSTR filepath)
{
return (_taccess(filepath, 00) == 0);
}
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
Another way:
<br />
WIN32_FIND_DATA wfd;<br />
<br />
HANDLE hFind = FindFirstFile(csFilePath, &wfd);<br />
if (hFind != INVALID_HANDLE_VALUE)
... <br />
Marc Soleda.
... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.
|
|
|
|
|
|
Try one of the stat functions, e.g.
int stat (const char *path, struct _stat *buffer);
|
|
|
|
|
PathFileExists can help tooo
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi
I have developed an application using the CBannerStatic class. For this I have used example given at : http://www.codeproject.com/staticctrl/bannerstatic2.asp
What I want is when I create EXE and run it, it should show the scrolling text. And I am statically adding the text at InitDialogue() function.
For this I am using a static control so display text. Now I want to show that static control into the size that user defines...Is there any way to dynamically change the size and position of the static control ?
Also I want to write a function such that if some one presses "ESC" key it will terminate the application. For this I have used ON_WM_CHAR, ON_WM_KEYDOWN but it's not working according to that any idea why it happens ?
Your kind help will be much important for me....
Regards
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Amarelia wrote:
For this I am using a static control so display text. Now I want to show that static control into the size that user defines...Is there any way to dynamically change the size and position of the static control ?
Sure, just use MoveWindow() or SetWindowPos() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi,
I have a Dialog based MFC app that is opening a modeless dialog. When I try
to minimize this window it minimizes to a small window just above the Start
button. Is there a simple way to make it minimize so that it appears in the
taskbar instead?
TIA,
Bob
|
|
|
|
|
When using laser printer to print, there is always a margin on the paper.
How to get the size of the margin?
How to ignore the margin, i mean, make my print CDC full scaled to the paper. In other way, which function in MFC printing is to set the printing CDC size.
Thanks!
|
|
|
|
|
Hi eveeryone,
I'm creating scheduling app like MS Outlook. I need some tip or algorithm for arranging events in timeline without overlaping like Outlook does.
Best regards,
Alex
|
|
|
|
|
When I use the API in a DLL project, I got an error:
HANDLE hPrinter = NULL;<br />
PDEVMODE pDevMode = NULL;<br />
char szPrinter = {"HP LaserJet 9050 PCL 6"};<br />
<br />
BOOL bOpen = ::OpenPrinter(szPrinter, &hPrinter, NULL);<br />
if (!bOpen || hPrinter == NULL) return;<br />
<br />
long nSize = ::DocumentProperties(NULL, hPrinter, szPrinter, NULL, NULL, 0);
DWORD dwErr = GetLastError();<br />
if (nSize < 0)<br />
{<br />
::ClosePrinter(hPrinter);<br />
return;<br />
}<br />
<br />
pDevMode = (PDEVMODE)new char[nSize];<br />
if (pBuffer == NULL)<br />
{<br />
::ClosePrinter(hPrinter);<br />
return;<br />
}<br />
<br />
memset(pBuffer, 0, LENGTH_DEVMODE);<br />
long nReturn = ::DocumentProperties(NULL, hPrinter, szPrinter, pDevMode, NULL, DM_OUT_BUFFER);<br />
::ClosePrinter(hPrinter);<br />
if (nReturn < 0)
return;
1.On Windows XP system:
if nSize = 6132, the last error will be 0, and print will succeed.
if nSize = -1, the last error will be 1114, and print will fail.
After "DocumentProperties()", the last error maybe 0 and sometimes maybe 1114. 0 means success while 1114 means "A dynamic link library (DLL) initialization routine failed".
2.On Windows 2000 professional I never got the error.
How can I avoid to fail to print?
|
|
|
|
|
baogangfeng wrote:
On Windows XP system, sometimes the value of nSize(size of the buffer) is -1...
You should be calling GetLastError() to find out why.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|