Thread: Code for a Coordinate Plane

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    202

    Post Code for a Coordinate Plane

    I am trying to program that will be able to do various transformations on a coordinate plane. But I am having 2 problems very early in the project. The first is what is the code to get the width/hight of a program. This will inturn be devided by two to get the halfway point for the Xand Y axi. The second problem is how can I designate the the hashmarks indication positions on the X and Y axis ( i.e. (0,1) and (1,0) ) without having them look like crap when they resize the program?

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You'll have to trap the WM_SIZE message. For this message the low order WORD of LPARAM will contain the wdith and the high order WORD will contain the height.

    I'm not sure what you mean in your second problem, but if you want to keep everything in proportion then you'll have to draw it in proportion. Something like one hash mark for every tenth of the size obtained by trapping the WM_SIZE (you have to store the values obtained in the WM_SIZE message in static variables).
    zen

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    By code for getting the width / height of the program do you mean the functions

    GetClientRect() or GetWindowRect()
    or
    iWidth =GetDeviceCaps(GetDC(NULL),HORZRES);
    iHeight =GetDeviceCaps(GetDC(NULL),VERTRES);

    for the screen area

    I assume you are using a HDC and also a framebuffer. If the user resizes the client area try using StretchBlt() to shrink/expand the framebuffer bmp to fit the new size. If the proportions (x/y) change you will have to redraw the original though.
    Try creating your HDC's/BMP's the same size as the max area (screen size usually). Have a function that draws based on the area sent to it. Call this in response to a WM_SIZE msg (pass it in the new size).
    I usually work out the biggest area within the ClientRect that will retain the graphs proportion and then send that to my drawing function. This will leave some area blank though.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Proposal: Code colouring
    By Perspective in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 05-14-2007, 07:23 AM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM