Frame 'flickering' in Windows XP Goodbye!
This function change the CommandButton style to a BS_GROUPBOX to transform it like a Frame control! This solve many problems (bad drawning controls, flickering, etc.).
AI
Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Zdrojový kód
-------------------------------- Open a new project, on Form1 add this controls: -------------------------------- - 1 CommandButton (Command1) - 1 OptionButton (Option1) - 1 TextBox (Text1) - Set Form1.ClipControls = False -------------------------------- Add this code to Form1: -------------------------------- Private Sub Form_Load() With Command1 .Caption = "Pseudo Frame" .Left = 300 .Top = 300 .ZOrder 1 End With With Text1 .Height = 330 .Left = 510 .Top = 600 End With With Option1 .Height = 330 .Left = 510 .Top = 1050 End With ChangeButtonStyle Command1, Me, 300, 300, 1800, 1800 End Sub -------------------------------- Add to Module this code -------------------------------- Public Sub ChangeButtonStyle(ByRef cmd As CommandButton, _ ByVal Parent As Object, _ Optional Left As Long = 0, _ Optional Top As Long = 0, _ Optional Width As Long = 0, _ Optional Height As Long = 0) '/ Show a CommandButton like a Frame control. '/ Also, set the backcolor text to the '/ background color On Error Resume Next '/ Change the CommandButton style SendMessage cmd.hWnd, BM_SETSTYLE, BS_GROUPBOX, 0 '/ Set the backcolor text to emulate the '/ transparent background cmd.BackColor = cmd.Container.BackColor '/ IMPORTANT: Set the TabStop property to false '/ otherwise when lost the focus pressing the TAB key '/ the style is changed to CheckBox '/ Also, the focus state don't need '/ with this pseudo-frame. cmd.TabStop = False '/ Optionally, you can move and size the '/ commandbutton (i.e. if you use a '/ PictureBox as Container: cmd.Move Left, Top, IIf(Width = 0, Parent.Width, Width), _ IIf(Height = 0, Parent.Height, Height) '/ IMPORTANT: This property MUST to be '/ set on Design-Time, otherwise '/ has not effect! '/ -------------------------------------- '/ Parent.ClipControls = False '/ -------------------------------------- End Sub
Původní komentáře (3)
Obnoveno z Wayback Machine