Главная страницаОбратная связьКарта сайта

Создание формы произвольных размеров



Создайте новый проект, разместите на форме элемент Label (чтобы выйти из
'программы).
'Обязательно установите в свойствах формы Caption = "" и ControlBox = False.

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long

Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2

Private Type POINTAPI
X As Long
Y As Long
End Type

Sub CutForm()
Dim P(428) As POINTAPI
Dim px
Dim py
Dim i As Integer
Dim Rgn As Long
px = Array(340, 339, 334, 333, 329, 328, 325, 324, 321, 320, 318, 317, 316, 315, 313, _
312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 301, 300, 298, 297, 294, 293, 281, 281, 278, 278, 277, 277, 275, 275, 274, 274, 273, 273, 272, 272, _
271, 271, 270, 270, 269, 268, 267, 265, 264, 263, 262, 260, 259, 258, 257, 256, 255, 254, 252, 251, 249, 248, 245, 195, 194, 188, 187, 187, 186, 186, _
185, 184, 182, 181, 180, 179, 178, 176, 175, 173, 172, 169, 168, 165, 164, 159, 158, 153, 152, 146, 145, 136, 135, 121, 120, 80, 79, 65, 64, 55, _
54, 48, 47, 42, 41, 36, 35, 32, 31, 28, 27, 25, 24, 22, 21, 20, 19, 18, 16, 15, 14, 14, 13, 13, 14, 14, 15, 16, 17, 18, _
19, 20, 21, 22, 24, 25, 27, 28, 31, 32, 35, 36, 41, 42, 47, 48, 54, 55, 64, 65, 67, 67, 64, 63, 61, 60, 57, 56, 54, 53, _
51, 50, 48, 47, 46, 45, 43, 42, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 24, 23, 21, 20, 13, 13, 11, _
11, 10, 10, 11, 11, 12, 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, _
36, 37, 38, 39, 40, 42, 43, 45, 46, 47, 48, 50, 51, 53, 54, 56, 57, 60, 61, 63, 64, 67, 68, 71, 72, 75, 76, 80, 81, 84, _
85, 89, 90, 95, 96, 100, 101, 106, 107, 113, 114, 120, 121, 128, 129, 136, 137, 146, 147, 158, 159, 172, 173, 194, 195, 254, 255, 276, 277, 290, _
291, 302, 303, 312, 313, 320, 321, 328, 329, 335, 336, 342, 343, 348, 349, 353, 354, 359, 360, 364, 365, 368, 369, 373, 374, 377, 378, 381, 382, 385, _
386, 388, 389, 392, 393, 395, 396, 398, 399, 401, 402, 403, 404, 406, 407, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, _
425, 426, 428, 429, 436, 436, 438, 438, 439, 439, 438, 438, 436, 436, 435, 435, 434, 434, 433, 433, 431, 431, 431, 431, 432, 432, 433, 433, 432, 432, _
431, 431, 430, 430, 429, 429, 428, 428, 427, 427, 426, 426, 425, 425, 423, 423, 422, 422, 419, 419, 407, 406, 403, 402, 400, 399, 397, 396, 395, 394, _
393, 392, 391, 390, 389, 388, 387, 385, 384, 383, 382, 380, 379, 376, 375, 372, 371, 367, 366, 360, 359, 341, 340, 339)

py = Array(182, 181, 181, 180, 180, 179, 179, 178, 178, 177, 177, 176, 176, 175, 175, _
174, 174, 173, 173, 172, 172, 171, 171, 170, 170, 168, 168, 166, 166, 163, 163, 151, 150, 147, 146, 145, 144, 142, 141, 140, 139, 138, 137, 136, 135, _
134, 132, 131, 129, 128, 128, 127, 127, 126, 126, 125, 125, 124, 124, 123, 123, 122, 122, 120, 120, 118, 118, 115, 115, 114, 114, 115, 118, 119, 120, _
121, 121, 123, 123, 124, 124, 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 133, 133, 132, 132, _
131, 131, 130, 130, 129, 129, 128, 128, 127, 127, 126, 126, 125, 125, 124, 124, 123, 123, 121, 121, 120, 119, 118, 115, 114, 113, 112, 112, 111, 110, _
110, 109, 109, 108, 108, 107, 107, 106, 106, 105, 105, 104, 104, 103, 103, 102, 102, 101, 101, 100, 100, 98, 98, 97, 97, 96, 96, 95, 95, 94, _
94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 81, 81, 79, 79, 72, 71, 69, _
67, 66, 60, 59, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, _
38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, _
23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 12, 12, 13, 13, _
14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, _
29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, _
45, 45, 47, 47, 54, 55, 57, 59, 60, 66, 67, 69, 71, 72, 73, 82, 83, 85, 86, 88, 90, 91, 93, 96, 97, 102, 103, 118, 119, 124, _
125, 128, 129, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 144, 145, 146, 147, 150, 151, 163, 163, 166, 166, 168, 168, 170, 170, 171, 171, _
172, 172, 173, 173, 174, 174, 175, 175, 176, 176, 177, 177, 178, 178, 179, 179, 180, 180, 181, 181, 182, 182, 181, 181)

For i = 0 To UBound(px)
P(i).X = px(i)
P(i).Y = py(i)
Next
Rgn = CreatePolygonRgn(P(0), 428, 0)
SetWindowRgn Form1.hwnd, Rgn, True
DeleteObject Rgn
End Sub

Private Sub Form_Load()
CutForm
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call ReleaseCapture
Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End Sub

Private Sub Label1_Click()
End
End Sub


Обсудить статью на форуме


Если Вас заинтересовала или понравилась информация программирование на Visual Basic - "Создание формы произвольных размеров", Вы можете поставить закладку в социальной сети или в своём блоге на данную страницу:

Так же Вы можете задать вопрос по работе этого модуля или примера через форму обратной связи, в сообщение обязательно указывайте название или ссылку на статью!
   


Copyright © 2008 - 2017 Дискета.info