Thread: Method of placing child window controls

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Method of placing child window controls

    Do you have a method? Pretty much what Petzold does is just use some ingenius multipliers to place then (with using something like the system font height/width).

    What do you do when creating the window and specifying placement? Anything better? Thanks...

    --Garfield
    1978 Silver Anniversary Corvette

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Not exactly sure what you are asking.

    I calculate where my controls should be, and their size, based on the screen size and client area of the parent window. I use hash defined percentages usually. Depends on how many and what type.

    If they are text ctrls, ie statics. I tend to use HDC's as these give me more formatting control. I use GetTextExtentPoint32() [on each string to be printed] to set position and ensure the size of the ctrl is big enough.
    "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

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    >> I use hash defined percentages usually. Depends on how many and what type. <<

    How do you do this? I (from Petzold) am just using calculations based on screen size too. I'm just curious if there is another way. Thanks...
    1978 Silver Anniversary Corvette

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    novacain, can you give me an example of how you would set your controls on your client? I am still using numerical (like 1, 2, 3 -- not vars or anything) to set it. It is pretty much trial and error. I don't think it should be like this. Thanks, novacain...
    1978 Silver Anniversary Corvette

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    It is mainly trial and error.

    If I wanted a listbox ctrl to take up half the dialog I would

    #define LB_WIDTH 0.5
    #define LB_HEIGHT 0.5

    then find the client rect and do the math

    iLBWidth=(ClientRect.right-ClientRect.left)*LB_WIDTH;
    iLBMargin=(int)((ClientRect.right-ClientRect.left)-iLBWidth)/2;

    ect.
    "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. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Parent not repainting Bitmp after child window closes
    By CodeX in forum Windows Programming
    Replies: 5
    Last Post: 10-05-2006, 12:03 AM
  4. Adding buttons, edit boxes, etc to the window
    By rainmanddw in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2006, 03:07 PM
  5. Child window controls & fonts
    By chomper in forum Windows Programming
    Replies: 0
    Last Post: 10-03-2001, 05:09 AM