Custom Interface In PowerBuilder
Declaration Of External Function:
1 2 |
Function Long CreateRoundRectRgn( Long nLeftRect, Long nTopRect, Long nRightRect, Long nBottomRect , Long nWidthEllipse, Long nHeightEllipse) Library "gdi32.dll" Function Long SetWindowRgn(Long hWnd,Long hRgn,Long bRedraw) Library "user32.dll" |
Example With Button
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
ULong hWnd Long li_newRgn Long nLeftRect // X-coordinate of upper-left corner Long nTopRect // Y-coordinate of upper-left corner Long nRightRect // X-coordinate of lower-right corner Long nBottomRect // Y-coordinate of lower-right corner ULong nWidthEllipse // width of ellipse ULong nHeightEllipse // height of ellipse nLeftRect = 3 nTopRect = 3 nRightRect = UnitsToPixels( This.Width, XUnitsToPixels! ) - 6 nBottomRect = UnitsToPixels( This.Height, YUnitsToPixels! ) - 6 nWidthEllipse = 20 nHeightEllipse = 20 hWnd = Handle( This ) li_newRgn = CreateRoundRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect, nWidthEllipse, nHeightEllipse) SetWindowRgn( hWnd, li_newRgn, 1 ) |
Example Window about
1 2 3 4 5 6 7 8 9 10 11 12 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
forward global type w_about from window end type type dw_1 from datawindow within w_about end type type p_1 from picture within w_about end type type str_wsadata from structure within w_about end type end forward type str_wsadata from structure unsignedinteger version unsignedinteger highversion character description[257] character systemstatus[129] unsignedinteger maxsockets unsignedinteger maxupddg string vendorinfo end type global type w_about from window integer width = 1947 integer height = 1092 boolean titlebar = true boolean controlmenu = true boolean minbox = true windowtype windowtype = popup! long backcolor = 134217739 string icon = "AppIcon!" boolean center = true dw_1 dw_1 p_1 p_1 end type global w_about w_about type prototypes Function Long CreateRoundRectRgn( Long nLeftRect, Long nTopRect, Long nRightRect, Long nBottomRect , Long nWidthEllipse, Long nHeightEllipse) Library "gdi32.dll" Function Long SetWindowRgn(Long hWnd,Long hRgn,Long bRedraw) Library "user32.dll" Function Boolean DeleteObject( ULong hObject ) Library "gdi32.dll" Function Int CombineRgn( ULong hrgnDest, ULong hrgnSrc1, ULong hrgnSrc2, Int fnCombineMode ) Library "gdi32.dll" Function Int SetWindowRgn( ULong wHandle, ULong rgHandle, Boolean redraw ) Library "user32.dll" Function ULong CreateEllipticRgn( Int nLeftRect, Int nTopRect, Int nRightRect, Int nBottomRect ) Library "gdi32.dll" Function Int WSAStartup (UInt UIVerionrequested, Ref str_wsadata lpWSAdata) Library "wsock32.DLL" Alias For "WSAStartup;ansi" Function Int WSACleanup() Library "wsock32.DLL" Function Int WSAGetLastError() Library "wsock32.DLL" Function Int gethostname(Ref String Name, Int namelen) Library "wsock32.DLL" Alias For "gethostname;Ansi" FUNCTION Long GetUserName (REF String lpBuffer, REF ULong lpnSize) LIBRARY "ADVAPI32.DLL" ALIAS FOR "GetUserNameA;ANSI" Function String GetHost(String lpszhost,Ref Blob lpszaddress) Library "pbws32.dll" Alias For "GetHost;Ansi" end prototypes type variables end variables forward prototypes public subroutine wf_load_form () public subroutine wf_set_data () public function string wf_get_windowname () public function string wf_computer () public function string wf_get_username () public function string wf_getip (ref string as_mac) end prototypes public subroutine wf_load_form ();//==================================================================== // Function: w_about.wf_load_form() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/04/03 //-------------------------------------------------------------------- // Usage: w_about.wf_load_form ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== ULong ll_handle_w, ll_handle_rec, ll_bottom Int li_width, li_height li_width = UnitsToPixels(This.Width ,XUnitsToPixels! ) li_height = UnitsToPixels(This.Height ,YUnitsToPixels! ) ll_handle_rec = CreateRoundRectRgn(0,25, li_width - 1, li_height - 1,li_height , li_height) ll_bottom = CreateEllipticRgn(80, li_height, li_width - 80 ,li_height - 50) ll_handle_w = Handle(This) SetWindowRgn(ll_handle_w, ll_handle_rec,True) //remove memory DeleteObject(ll_handle_rec) DeleteObject(ll_bottom) end subroutine public subroutine wf_set_data ();String ls_window String ls_computer String ls_username String ls_ip, ls_mac ls_window = wf_get_windowname() ls_computer = wf_computer() ls_username = wf_get_username() ls_ip = wf_getip(ls_mac) dw_1.setitem(dw_1.getrow(),'as_ip',ls_ip) dw_1.setitem(dw_1.getrow(),'as_netcard',ls_mac) dw_1.setitem(dw_1.getrow(),'as_window',ls_window) dw_1.setitem(dw_1.getrow(),'as_computer',ls_computer) dw_1.setitem(dw_1.getrow(),'as_user',ls_username) end subroutine public function string wf_get_windowname ();//==================================================================== // Function: w_about.wf_get_windowname() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/04/03 //-------------------------------------------------------------------- // Usage: w_about.wf_get_windowname ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_osversion,ls_osedition,ls_csdversion Long ll_BuildNumber String ls_windowname nvo_func luo_sys luo_sys = Create nvo_func luo_sys.of_getosversion( ls_osversion,ls_osedition,ls_csdversion,ll_BuildNumber) Destroy luo_sys ls_windowname = ls_osversion + ' ' + ls_osedition + ' ' + ls_csdversion + ' Build(' + String(ll_BuildNumber) + ')' Return ls_windowname end function public function string wf_computer ();//==================================================================== // Function: w_about.wf_computer() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/04/03 //-------------------------------------------------------------------- // Usage: w_about.wf_computer ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_host Blob{4} lb_host Integer li_version, li_rc str_wsadata lstr_wsadata ls_host = Space(128) li_version = 257 If WSAStartup(li_version, lstr_wsadata) = 0 Then GetHostName(ls_host, Len(ls_host)) li_rc = WSAGetLastError() End If WSACleanup() Return ls_host end function public function string wf_get_username ();//==================================================================== // Function: w_about.wf_get_username() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2021/04/03 //-------------------------------------------------------------------- // Usage: w_about.wf_get_username ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_UserName ULong ll_NameLength Long ll_ret ll_NameLength = 255 ls_UserName = Space (ll_NameLength) ll_ret = GetUserName(ls_UserName, ll_NameLength) Return ls_UserName end function public function string wf_getip (ref string as_mac);String ls_ip String ls_macaddress[],ls_description[],ls_adaptername[],ls_ipaddress[] Long ll_array nvo_func luo_func luo_func = Create nvo_func luo_func.of_getadaptersinfo(ls_macaddress,ls_description,ls_adaptername,ls_ipaddress) If UpperBound(ls_ipaddress) > 0 Then For ll_array = 1 To UpperBound(ls_ipaddress) ls_ip = ls_ipaddress[ll_array] If Pos(ls_ip, ';') > 0 Then ls_ip = Mid(ls_ip, 1, Pos(ls_ip, ';') - 1) If long(mid(ls_ip,1,1)) <> 0 Then //return ls_ip Exit; Else //return ls_ip End IF Next End IF destroy luo_func If UpperBound(ls_macaddress) > 0 Then as_mac = ls_macaddress[1] End If return ls_ip end function on w_about.create this.dw_1=create dw_1 this.p_1=create p_1 this.Control[]={this.dw_1,& this.p_1} end on on w_about.destroy destroy(this.dw_1) destroy(this.p_1) end on event open;String ls_file Boolean lb_flag dw_1.InsertRow(0) wf_load_form() wf_set_data() end event type dw_1 from datawindow within w_about event ue_dwmousemove pbm_dwnmousemove integer x = 251 integer y = 184 integer width = 1413 integer height = 620 integer taborder = 20 string title = "none" string dataobject = "d_about" boolean border = false boolean livescroll = true end type event ue_dwmousemove;String ls_dwoname_pic1,ls_dwoname_pic2 String ls_modify_1, ls_modify_2,ls_modify_3, ls_modify_4,ls_modify_5,ls_modify_6,ls_modify_7 Integer li_pos Long i, ll_rowcount,il_MoveCursor String ls_chk_safe,ls_favourite String ls_dwoname_pat1,ls_dwoname_pat2,ls_dwoname,ls_dwoname_label Long ll_buttonface,ll_navy //== ls_dwoname = String(dwo.name) li_pos = Pos(ls_dwoname, 'b_close1') If li_pos = 0 Then li_pos = Pos(ls_dwoname, 'b_close') End If If li_pos > 0 Then //For i = 1 To ll_rowcount If ls_dwoname = 'b_close1' Then ls_modify_1 = "b_close1.visible = False" ls_modify_2 = "b_close.visible = True" Else If ls_dwoname = 'b_close' Then ls_modify_1 = "b_close1.visible = False" ls_modify_2 = "b_close.visible = True" Else ls_modify_1 = "b_close1.visible = True" ls_modify_2 = "b_close.visible = False" End If End If This.Modify(ls_modify_1) This.Modify(ls_modify_2) Else ls_modify_1 = "b_close1.visible = True" ls_modify_2 = "b_close.visible = False" This.Modify(ls_modify_1) This.Modify(ls_modify_2) End If end event event buttonclicked;Choose Case dwo.name Case 'b_close','b_close1' Close(parent) End Choose end event event clicked;Choose Case dwo.name Case 'b_close' Close(parent) End Choose end event type p_1 from picture within w_about integer width = 1929 integer height = 1008 string picturename = "about.gif" boolean focusrectangle = false end type |
Example button object
1 2 3 4 5 6 7 8 9 10 11 12 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
forward global type uo_commanbutton from userobject end type type st_text from statictext within uo_commanbutton end type end forward global type uo_commanbutton from userobject integer width = 453 integer height = 108 long backcolor = 67108864 long tabtextcolor = 33554432 long picturemaskcolor = 536870912 event ue_lbuttondown pbm_lbuttondown event dd pbm_bndoubleclicked event ue_lbuttondblclk pbm_lbuttondblclk event clicked pbm_lbuttonup st_text st_text end type global uo_commanbutton uo_commanbutton type prototypes //FUNCTION ulong CreateRoundRectRgn(ulong X1,ulong Y1,ulong X2,ulong Y2,ulong X3,ulong Y3) LIBRARY "gdi32.dll" FUNCTION ulong SetWindowRgn(ulong hWnd,ulong hRgn,boolean bRedraw) LIBRARY "user32.dll" Function Long CreateRoundRectRgn( Long nLeftRect, Long nTopRect, Long nRightRect, Long nBottomRect , Long nWidthEllipse, Long nHeightEllipse) Library "gdi32.dll" Function Long SetWindowRgn(Long hWnd,Long hRgn,Long bRedraw) Library "user32.dll" end prototypes type variables CONSTANT long il_number= 5.7 boolean ib_bold = false //400-700 boolean ib_underline = false //Underline boolean ib_strkeout = false //Strikethrough int ii_fontsize=18 string is_text = "Text" long il_ClickedColor = 14589000,il_color = 14120960//il_HoveColor = 14727818, long il_FontColor = 16777215 long il_radian = 5 end variables forward prototypes public subroutine of_draw (integer as_choose) end prototypes event ue_lbuttondown;of_draw(1) end event event ue_lbuttondblclk;of_draw(1) end event event clicked;of_draw(0) end event public subroutine of_draw (integer as_choose);//==================================================================== // Function: uo_commanbutton.of_draw() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value integer as_choose //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Usage: uo_commanbutton.of_draw ( integer as_choose ) //==================================================================== String ls_err,ls_syntax Long ll_width,ll_height Long ll_y = 0,ll_x = 0 ll_width = This.Width ll_height = il_number * ii_fontsize ll_y = (10+This.Height - ll_height) / 2 Choose Case as_choose Case 0 This.BackColor = il_color st_text.BackColor = il_color Case 1 ll_x = 5 ll_y = ll_y + 5 This.BackColor = il_ClickedColor st_text.BackColor = il_ClickedColor Case 1 End Choose st_text.X = ll_x st_text.Y = ll_y st_text.Text = is_text st_text.TextSize = -ii_fontsize st_text.Width = ll_width st_text.Height = This.Height st_text.TextColor = il_FontColor If ib_bold Then st_text.Weight = 700 Else st_text.Weight = 400 End If st_text.Underline = ib_underline st_text.Italic = ib_strkeout // arc angle Long ll_Rgn ll_width = UnitsToPixels(This.Width,Xunitstopixels!) ll_height = UnitsToPixels(This.Height, Yunitstopixels!) ll_Rgn = Createroundrectrgn(0,0,ll_width,ll_height,il_radian,il_radian) Setwindowrgn(Handle(This),ll_Rgn,True) end subroutine on uo_commanbutton.create this.st_text=create st_text this.Control[]={this.st_text} end on on uo_commanbutton.destroy destroy(this.st_text) end on event constructor;of_draw(0) end event type st_text from statictext within uo_commanbutton integer width = 457 integer height = 76 integer textsize = -18 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 boolean enabled = false alignment alignment = center! boolean focusrectangle = false end type |
Find Projects On Github click here
Good Luck!
Subscribe
Login
0 Comments