Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Geo Location Pin
Cedric Moonen6-May-10 20:16
Cedric Moonen6-May-10 20:16 
QuestionRe: Geo Location Pin
David Crow6-May-10 2:58
David Crow6-May-10 2:58 
AnswerRe: Geo Location Pin
Emilio Garavaglia7-May-10 0:05
Emilio Garavaglia7-May-10 0:05 
QuestionSet size and postion of contols in c++ win 32 Pin
arun_pk5-May-10 23:47
arun_pk5-May-10 23:47 
AnswerRe: Set size and postion of contols in c++ win 32 Pin
csrss5-May-10 23:57
csrss5-May-10 23:57 
GeneralRe: Set size and postion of contols in c++ win 32 Pin
arun_pk6-May-10 0:00
arun_pk6-May-10 0:00 
GeneralRe: Set size and postion of contols in c++ win 32 Pin
CPallini6-May-10 0:15
mveCPallini6-May-10 0:15 
GeneralRe: Set size and postion of contols in c++ win 32 Pin
enhzflep6-May-10 0:25
enhzflep6-May-10 0:25 
Here's a mickey mouse example.

It assumes a child control (a button in my instance) exists and has the ID of IDC_BUTTON1 (#define IDC_BUTTON1 1000)

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wWidth, wHeight;
    int bWidth, bHeight;
    RECT btnRect;
    HWND btnHwnd;
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;

        case WM_SIZE:
            // get size of the parent window's client area
            wWidth = LOWORD(lParam);
            wHeight = HIWORD(lParam);

            //  get RECT of the button (in parent's client coords)
            btnHwnd = GetDlgItem(hwnd, IDC_BUTTON1);
            GetWindowRect(btnHwnd, &btnRect);

            // determine it's dimensions
            bWidth = btnRect.right - btnRect.left;
            bHeight = btnRect.bottom - btnRect.top;

            // move it so that it retains its width and height, and is centered on the parent window.
            SetWindowPos(btnHwnd, HWND_TOP, (wWidth-bWidth)/2, (wHeight-bHeight)/2, bWidth, bHeight, SWP_SHOWWINDOW);
            break;

        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

GeneralRe: Set size and postion of contols in c++ win 32 Pin
arun_pk6-May-10 2:17
arun_pk6-May-10 2:17 
GeneralRe: Set size and postion of contols in c++ win 32 Pin
enhzflep6-May-10 10:24
enhzflep6-May-10 10:24 
QuestionRe: Set size and postion of contols in c++ win 32 Pin
David Crow6-May-10 3:00
David Crow6-May-10 3:00 
Questionwin32 and gtk+ (vista glass) :( Pin
csrss5-May-10 23:30
csrss5-May-10 23:30 
Questionwindow Position C++ win32 Pin
arun_pk5-May-10 22:14
arun_pk5-May-10 22:14 
AnswerRe: window Position C++ win32 Pin
CPallini5-May-10 22:20
mveCPallini5-May-10 22:20 
GeneralRe: window Position C++ win32 Pin
arun_pk5-May-10 23:39
arun_pk5-May-10 23:39 
GeneralRe: window Position C++ win32 Pin
CPallini6-May-10 0:13
mveCPallini6-May-10 0:13 
AnswerRe: window Position C++ win32 Pin
Michel Godfroid5-May-10 22:22
Michel Godfroid5-May-10 22:22 
GeneralRe: window Position C++ win32 Pin
arun_pk5-May-10 23:39
arun_pk5-May-10 23:39 
AnswerRe: window Position C++ win32 Pin
Stuart Dootson6-May-10 0:14
professionalStuart Dootson6-May-10 0:14 
QuestionCreating API for my application... Pin
Shy Agam5-May-10 22:09
Shy Agam5-May-10 22:09 
AnswerRe: Creating API for my application... Pin
CPallini5-May-10 22:14
mveCPallini5-May-10 22:14 
AnswerRe: Creating API for my application... Pin
Michel Godfroid5-May-10 22:26
Michel Godfroid5-May-10 22:26 
QuestionDll pacement Pin
krishna_CP5-May-10 21:56
krishna_CP5-May-10 21:56 
AnswerRe: Dll pacement Pin
CPallini5-May-10 22:12
mveCPallini5-May-10 22:12 
AnswerRe: Dll pacement Pin
Cedric Moonen5-May-10 22:14
Cedric Moonen5-May-10 22:14 

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.