PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: center control  (Read 125 times)

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
center control
« on: June 13, 2020, 08:01:43 AM »

Josť,
  What is the best way to center a control Vertically or Horizontally on a CWindow?
Does the framework provide such a procedure?
I am experimenting with a CXpButton and the old framework I ported to bc9Basic.

  Thank you and be safe,

James
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9287
  • Windows 10
    • PlanetSquires Software
Re: center control
« Reply #1 on: June 13, 2020, 08:06:04 AM »

Jose's WinFBX library has functions in AfxWin.inc to do this:

' ========================================================================================
' Centers a control horizontally.
' hCtrl = Handle of the control.
' ========================================================================================
PRIVATE SUB AfxCenterControlH (BYVAL hCtrl AS HWND)


' ========================================================================================
' Centers a control vertically
' hCtrl = Handle of the control.
' ========================================================================================
PRIVATE SUB AfxCenterControlV (BYVAL hCtrl AS HWND)


' ========================================================================================
' Centers a window on the screen or over another window.
' It also ensures that the placement is done within the work area.
' Parameters:
' - hwnd = Handle of the window.
' - hwndParent = [optional] Handle of the parent window.
' ========================================================================================
PRIVATE SUB AfxCenterWindow (BYVAL hwnd AS HWND = NULL, BYVAL hwndParent AS HWND = NULL)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3268
Re: center control
« Reply #2 on: June 13, 2020, 08:11:37 AM »

Funny that I wrote AfxCenterControlH and AfxCenterControlV because he asked me to do it :)

See: https://www.planetsquires.com/protect/forum/index.php?topic=3956.msg29555#msg29555

« Last Edit: June 13, 2020, 08:26:16 AM by Josť Roca »
Logged

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: center control
« Reply #3 on: June 13, 2020, 09:40:37 AM »

Guys,
  I'm lucky I remember what day it is.  A forum post from 4 years ago, not likely  :)
Thank you,

James
Logged

James Fuller

  • Senior Member
  • ***
  • Posts: 305
  • FF3 User
Re: center control
« Reply #4 on: June 13, 2020, 10:14:52 AM »

I probably would have found it on my own but I was using the wrong include file that did not have them.
Thanks again

James

Logged