Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Shipping .h files for .DLL classes Pin
Peter Weyzen10-Jun-03 20:21
Peter Weyzen10-Jun-03 20:21 
GeneralMix casing a name field Pin
Bryster10-Jun-03 4:13
Bryster10-Jun-03 4:13 
GeneralRe: Layered window problem Pin
Bedas10-Jun-03 4:11
Bedas10-Jun-03 4:11 
GeneralRe: Layered window problem Pin
Ryan Binns10-Jun-03 4:26
Ryan Binns10-Jun-03 4:26 
Questionhow to size an app to fit a PC's display size Pin
johnstonsk10-Jun-03 4:06
johnstonsk10-Jun-03 4:06 
AnswerRe: how to size an app to fit a PC's display size Pin
Florin Ochiana10-Jun-03 4:17
Florin Ochiana10-Jun-03 4:17 
GeneralRe: how to size an app to fit a PC's display size Pin
Ryan Binns10-Jun-03 4:37
Ryan Binns10-Jun-03 4:37 
AnswerRe: how to size an app to fit a PC's display size Pin
Ryan Binns10-Jun-03 4:35
Ryan Binns10-Jun-03 4:35 
If you only want it to work with a single-monitor system, then using GetSystemMetrics() with the SM_CXSCREEN and SM_CYSCREEN indexes will give you the width and height of the screen.

If you want it to work with multiple monitors (highly recommended), then it's a bit more complicated. Use EnumMonitors(). Something like this, called from inside your one of your window's functions, probably OnCreate():
BOOL CALLBACK monitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
{
    if(hMonitor != NULL)
    {
        CWnd *pWnd = (CWnd*)dwData;
        if(pWnd != NULL)
            pWnd->MoveWindow(lprcMonitor);
    }
    return TRUE;
}

int CMyWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...
    CDC *pDC = GetDC();
    EnumMonitors(pDC->GetSafeHdc(), NULL, monitorEnumProc, (LPARAM)this);
    ReleaseDC(pDC);
    ...
}
EnumMonitors() will call the callback function once for every monitor that the specified device context (taken from your window) is on, which may be more than one. However, Windows always creates a top-level window such that it never spans more than one monitor, so from OnCreate() it should only call the callback function once. You can guarantee it's only called once by returning FALSE from the callback function instead of TRUE, if you want to.

Hope this helps. I haven't tested this code, but I've done it before (I just hope my memory is correct Smile | :) )

Ryan

Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)

Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"

GeneralRe: how to size an app to fit a PC's display size Pin
johnstonsk10-Jun-03 7:43
johnstonsk10-Jun-03 7:43 
GeneralOleCreateFromFile Pin
Florin Ochiana10-Jun-03 3:56
Florin Ochiana10-Jun-03 3:56 
GeneralCRichEditCtrl FormatRange Bounding Rectangle Pin
Larry J. Siddens10-Jun-03 3:48
Larry J. Siddens10-Jun-03 3:48 
GeneralRe: CRichEditCtrl FormatRange Bounding Rectangle Pin
Larry J. Siddens11-Jun-03 2:36
Larry J. Siddens11-Jun-03 2:36 
GeneralCatch the "enter" Pin
Woltan10-Jun-03 3:34
Woltan10-Jun-03 3:34 
GeneralRe: Catch the "enter" Pin
Maximilien10-Jun-03 3:44
Maximilien10-Jun-03 3:44 
GeneralRe: Catch the "enter" Pin
Mike Dimmick10-Jun-03 6:12
Mike Dimmick10-Jun-03 6:12 
GeneralRe: Catch the "enter" Pin
Florin Ochiana10-Jun-03 4:15
Florin Ochiana10-Jun-03 4:15 
Generalget_innerText Pin
Majid Shahabfar10-Jun-03 3:26
Majid Shahabfar10-Jun-03 3:26 
GeneralRe: get_innerText Pin
David Crow10-Jun-03 6:58
David Crow10-Jun-03 6:58 
General#define macro expansions Pin
David Chamberlain10-Jun-03 3:06
David Chamberlain10-Jun-03 3:06 
GeneralRe: #define macro expansions Pin
basementman10-Jun-03 3:55
basementman10-Jun-03 3:55 
GeneralRe: #define macro expansions Pin
David Chamberlain10-Jun-03 4:36
David Chamberlain10-Jun-03 4:36 
GeneralRe: #define macro expansions Pin
Peter Weyzen10-Jun-03 20:26
Peter Weyzen10-Jun-03 20:26 
GeneralRe: #define macro expansions Pin
Iain Clarke, Warrior Programmer10-Jun-03 4:03
Iain Clarke, Warrior Programmer10-Jun-03 4:03 
GeneralIntersecting windows Pin
pankajdaga10-Jun-03 3:02
pankajdaga10-Jun-03 3:02 
GeneralRe: Intersecting windows Pin
basementman10-Jun-03 3:59
basementman10-Jun-03 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.