Results 1 to 7 of 7

Thread: Form Left Edge Width, Form Top Caption and Menu Height

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    170

    Form Left Edge Width, Form Top Caption and Menu Height

    I need to get the global X,Y Coordinates of the upper left corner of a form surface so to do so I need to know edge width and form caption height and mu height.

    Not the top left of the form.
    The form may or may not have a Menu showing.

    So it needs to take into account the form left edge width, the form caption and the menu height.

    Help please.

  2. #2
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,918

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    Use GetWindowRect and GetClientRect API functions to get the rectangles for the whole window and its client area respectively.

    WindowWidth is WindowRect.Right - WindowRect.Left
    ClientWidth is ClientRect.Right - ClientRect.Left

    EdgeWidth is (WindowWidth - ClientWidth) \ 2.
    TitlebarHeight (with menu if any) is WindowHeight - ClientHeight - EdgeWidth

  3. #3
    Addicted Member
    Join Date
    Jul 2021
    Posts
    249

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    - OR - Just use ClientToScreen to get the screen coordinates of point (0,0)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    170

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    To clarify, if I understand correctly, GetClientRect gets the coordinates of what I call the form canvas or the area on the form surface that I can draw on.

    But if the cursor goes off the form what do I get ?

  5. #5
    PowerPoster
    Join Date
    Jan 2020
    Posts
    4,182

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    maybe like this
    Attached Images Attached Images  

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,467

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    Quote Originally Posted by LorinM View Post
    To clarify, if I understand correctly, GetClientRect gets the coordinates of what I call the form canvas or the area on the form surface that I can draw on.

    But if the cursor goes off the form what do I get ?
    Not sure what the cursor has to do with GetClientRect.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2009
    Location
    Anywhere I want to.
    Posts
    170

    Re: Form Left Edge Width, Form Top Caption and Menu Height

    Forget it.
    I am now using system metrics to get the cursor position over my canvas.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width