• Welcome to PlanetSquires Forums.
 

center control

Started by James Fuller, June 13, 2020, 08:01:43 AM

Previous topic - Next topic

James Fuller

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

Paul Squires

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)
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#2
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


James Fuller

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

James

James Fuller

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