ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   re-post border on userforms (https://www.excelbanter.com/excel-programming/377590-re-post-border-userforms.html)

new_to_vba

re-post border on userforms
 
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not defined.
with the findwindow highlighted.

any help would be great. new_to_vba

new_to_vba

re-post border on userforms
 
Forgot to mention that this is a code given to me by Micheal Pieron.
sorry for not giving you credit for that Micheal, it was not my intention.
regards new_to_vba

"new_to_vba" wrote:

having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not defined.
with the findwindow highlighted.

any help would be great. new_to_vba


NickHK

re-post border on userforms
 
You do know that FindWindow and SetWindowLong are part of the windows API,
so VBA does not know anything about them ?
You have to include their declarations, so VBA can understand the call.

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal
hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

The API-Guide from http://www.allapi.net/ will help you.

Also it may help if you defined constants for -16, -20, etc giving them a
descriptive name, so others (or yourself in 6 months time) can understand
what they mean and what you are trying to do.
e.g. Public Const WM_DRAWCLIPBOARD = &H308

NickHK

"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not

defined.
with the findwindow highlighted.

any help would be great. new_to_vba




Nigel

re-post border on userforms
 
FindWindow is a function that needs to be included in the userform code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba




new_to_vba

re-post border on userforms
 
seems like i am making one mistake after another,
here is the full code given to me. i think i have put it in the right places.
ie. "insert module" for the module section and in the userform for the
"userform initialize" section.

new_to_vba

"Nigel" wrote:

FindWindow is a function that needs to be included in the userform code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba





new_to_vba

re-post border on userforms
 
done it again forgot to include code.
try this.

In the UserForm module:

Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex& _
, ByVal wNewWord&)
' If you want to be able to move UserForm
Private Declare Function ReleaseCapture& Lib "user32" ()
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg& _
, ByVal wParam%, ByVal lParam As Any)

Private hWnd&

' You need a button to close UserForm
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

' If you want to be able to move UserForm
Private Sub UserForm_MouseDown(ByVal Button%, ByVal Shift%, ByVal X!, ByVal
Y!)
ReleaseCapture
SendMessage hWnd, &HA1, 2, 0&
End Sub


"new_to_vba" wrote:

seems like i am making one mistake after another,
here is the full code given to me. i think i have put it in the right places.
ie. "insert module" for the module section and in the userform for the
"userform initialize" section.

new_to_vba

"Nigel" wrote:

FindWindow is a function that needs to be included in the userform code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba





NickHK

re-post border on userforms
 
Whilst that 'works', it gives pretty ugly results. I had a quick look and
this is gives cleaner results:
http://www.experts-exchange.com/Appl..._21918621.html

NickHK

"new_to_vba" wrote in message
...
done it again forgot to include code.
try this.

In the UserForm module:

Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex& _
, ByVal wNewWord&)
' If you want to be able to move UserForm
Private Declare Function ReleaseCapture& Lib "user32" ()
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg& _
, ByVal wParam%, ByVal lParam As Any)

Private hWnd&

' You need a button to close UserForm
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

' If you want to be able to move UserForm
Private Sub UserForm_MouseDown(ByVal Button%, ByVal Shift%, ByVal X!,

ByVal
Y!)
ReleaseCapture
SendMessage hWnd, &HA1, 2, 0&
End Sub


"new_to_vba" wrote:

seems like i am making one mistake after another,
here is the full code given to me. i think i have put it in the right

places.
ie. "insert module" for the module section and in the userform for the
"userform initialize" section.

new_to_vba

"Nigel" wrote:

FindWindow is a function that needs to be included in the userform

code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba






new_to_vba

re-post border on userforms
 
i must be doing something wrong as i cant get either to work.
thanks anyway New_to_vba

"NickHK" wrote:

Whilst that 'works', it gives pretty ugly results. I had a quick look and
this is gives cleaner results:
http://www.experts-exchange.com/Appl..._21918621.html

NickHK

"new_to_vba" wrote in message
...
done it again forgot to include code.
try this.

In the UserForm module:

Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex& _
, ByVal wNewWord&)
' If you want to be able to move UserForm
Private Declare Function ReleaseCapture& Lib "user32" ()
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg& _
, ByVal wParam%, ByVal lParam As Any)

Private hWnd&

' You need a button to close UserForm
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

' If you want to be able to move UserForm
Private Sub UserForm_MouseDown(ByVal Button%, ByVal Shift%, ByVal X!,

ByVal
Y!)
ReleaseCapture
SendMessage hWnd, &HA1, 2, 0&
End Sub


"new_to_vba" wrote:

seems like i am making one mistake after another,
here is the full code given to me. i think i have put it in the right

places.
ie. "insert module" for the module section and in the userform for the
"userform initialize" section.

new_to_vba

"Nigel" wrote:

FindWindow is a function that needs to be included in the userform

code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba







NickHK

re-post border on userforms
 
With API calls, you really should declare all functions with their return
value and check it.
Then you will know which call is failing.

NickHK

"new_to_vba" wrote in message
...
i must be doing something wrong as i cant get either to work.
thanks anyway New_to_vba

"NickHK" wrote:

Whilst that 'works', it gives pretty ugly results. I had a quick look

and
this is gives cleaner results:

http://www.experts-exchange.com/Appl..._21918621.html

NickHK

"new_to_vba" wrote in message
...
done it again forgot to include code.
try this.

In the UserForm module:

Private Declare Function FindWindow& Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function SetWindowLong& Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex& _
, ByVal wNewWord&)
' If you want to be able to move UserForm
Private Declare Function ReleaseCapture& Lib "user32" ()
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg& _
, ByVal wParam%, ByVal lParam As Any)

Private hWnd&

' You need a button to close UserForm
Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

' If you want to be able to move UserForm
Private Sub UserForm_MouseDown(ByVal Button%, ByVal Shift%, ByVal X!,

ByVal
Y!)
ReleaseCapture
SendMessage hWnd, &HA1, 2, 0&
End Sub


"new_to_vba" wrote:

seems like i am making one mistake after another,
here is the full code given to me. i think i have put it in the

right
places.
ie. "insert module" for the module section and in the userform for

the
"userform initialize" section.

new_to_vba

"Nigel" wrote:

FindWindow is a function that needs to be included in the userform

code.
Where you sourced this code should have provided this as well.?

--
Cheers
Nigel



"new_to_vba" wrote in message
...
having trouble with the following code,

Private Sub UserForm_Initialize()
' Title bar is a skin - resize UserForm dimensions
Me.Height = Me.InsideHeight + ((Me.Width - Me.InsideWidth) / 2)
Me.Width = Me.InsideWidth
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080 ' No caption
SetWindowLong hWnd, -20, &H40000 ' No borders
End Sub

when i open my workbook i get a compile error, sub or function

not
defined.
with the findwindow highlighted.

any help would be great. new_to_vba










All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com