C++ Win32 GDI+ Scaling Shapes with Windows Resizing

Hi
i just started Win32 for my School project
and i have a problem in it
when i create some shapes like lines or beziers
when i resize the window, the shape does not resize with it.
I found a Article about it in here

zeuscmd.com/tutorials/opengl/09-WindowResizing.php

but i don't know that much coding to find out where to put the code or it will work for GDI+ shapes or it's only work for OpenGL and glut
for the moment i'm looking for a method to make shapes based on window's size
so, something like this

WH // Window's Height
WW // Window's Width
MWX = MIN(WH,WW)
PMWX = MWX/100

VOID DrawLine(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawLine(&pen, PMWX *0, PMWX *0, PMWX *200, PMWX *100);
}

so if it work, shapes are based on Windows size, and are totally redraw ones
so even if the shape be a 2 pixel one
changing the window size making it redraw without increasing line thickness
or miss judging because of scaling single pixels too

if this method will work how can i make a public variable for windows Height and Width
and if this is not the right way to do it how can i do it
thank you




Last edited on
You can get the window client size with GetClientRect():

1
2
3
4
5
RECT r;
GetClientRect(hwnd, &r);

winwidth = r.right - r.left;
winheight = r.bottom - r.top;


Or, handle WM_SIZE/WM_SIZING messages:

1
2
3
4
5
6
7
8
9
switch (msg)
{
     case WM_SIZE:
     case WM_SIZING:
          winwidth = LOWORD(lparam);
          winheight = HIWORD(lparam);

          return 0;
}
Last edited on
Topic archived. No new replies allowed.