03-28-2005, 07:19 AM
Design your GUI Sample
|
03-28-2005, 12:28 PM
Awesome work! Will take a glance as soon as I get to my Windows box.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio underBASIC, homegrown musicians [img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
03-28-2005, 04:51 PM
:o Great!!! Do you plan to implement other controls, (Progress Bars etc.)?
03-28-2005, 08:19 PM
Thanks Qbos, na_th_an
I plan on more controls later. If you have some working FreeBasic code, I could get it in sooner, I have never used a progress bar. I'll see if I can find one somewhere. Thanks ....Jerry Fielden
03-28-2005, 08:24 PM
dont you think the code is a bit excessive for just a few controls?
03-28-2005, 09:52 PM
Quote:dont you think the code is a bit excessive for just a few controls? Not all that code is to display the controls. There is probably better ways to detect radiobuttons and listboxes and populate Listviews and get text from edit controls. But I haven't got there yet. It's just beginner code, like I explained. That code don't have to be used anyway, it's just a Sample. There is two other Builds to select from the submenu, working window (windows that displays) or parent and controls only that gives 800x600 screen location address, less example in those. It's just a sample maker, nothing fancy or brilliant. And I can change things that needs to be changed, just tell me what. If anybody has a morebetter way on any of this, let me know, I'll be glad to change it. I'm not a SDK programmer, I just mess with it once in a while. I'm not really a programmer, only when the sun don't shine and it's too cold or too hot or too wet to get outside. Later.........Jerry Fielden
03-29-2005, 04:35 AM
TBBQ, GUI code at the most basic level isn't trivial, ya know...
I'd knock on wood, but my desk is particle board.
03-31-2005, 06:19 AM
Good Evening:
If you have win98 and you notice that the sample on the EzeeGUI Sample Code page would GPF when compiled with win FreeBasic 12, fbc-0.13 posted by Lillo in the Help forum doesn't do that. RichEdit and Listview were the Controls not working with ver12. Lillo posted this in Kernal32.dll problems in win98: http://www.ecplusplus.com/fbc-0.13-cvs-win32.zip Have a Good one.....Jerry Fielden
03-31-2005, 02:43 PM
FB v0.13(cvs) doesn't work on my machine (Win95OSR2). Instead, I re-arrange the code and add hInst as a shared variable and RichTxt1 string as a fixed 80 chars lenght of string. Thats all I remember which was the caused the crash. Anything else, I can't explain how it works since I'm too newbie (I think nothing else that caused any failures). Probably expert could explain from my modified code below.
Screenshot: Support Image (Convert and save as sonya15.bmp in the same directory): Source Code (for fb v0.12): [syntax="QBasic"] #DEFINE EM_SETOPTIONS WM_USER + 77 #DEFINE ES_DISABLENOSCROLL &H00002000 #DEFINE ES_SAVESEL &H00008000 #DEFINE ECOOP_OR &H0002 #DEFINE ECO_SELECTIONBAR &H01000000 OPTION EXPLICIT ' $INCLUDE: 'win\kernel32.bi' ' $INCLUDE: 'win\user32.bi' ' $INCLUDE: 'win\GDI32.bi' ' $INCLUDE :'win\COMMCTRL32.bi' TYPE LV_ITEM mask AS uinteger iItem AS LONG iSubItem AS LONG STATE AS uinteger stateMask AS uinteger pszText AS string ptr cchTextMax AS LONG iImage AS LONG lParam AS LONG iIndent AS LONG END TYPE TYPE LV_COLUMN mask AS uinteger fmt AS LONG cx AS LONG pszText AS string ptr cchTextMax AS LONG iSubItem AS LONG iImage AS LONG iOrder AS LONG END TYPE TYPE NEWTEXTMETRIC tmHeight AS LONG tmAscent AS LONG tmDescent AS LONG tmInternalLeading AS LONG tmExternalLeading AS LONG tmAveCharWidth AS LONG tmMaxCharWidth AS LONG tmWeight AS LONG tmOverhang AS LONG tmDigitizedAspectX AS LONG tmDigitizedAspectY AS LONG tmFirstChar AS BYTE tmLastChar AS BYTE tmDefaultChar AS BYTE tmBreakChar AS BYTE tmItalic AS BYTE tmUnderlined AS BYTE tmStruckOut AS BYTE tmPitchAndFamily AS BYTE tmCharSet AS BYTE ntmFlags AS UINTEGER ntmSizeEM AS UINTEGER ntmCellHeight AS UINTEGER ntmAveWidth AS UINTEGER END TYPE TYPE ENUMLOGFONT elfLogFont AS LOGFONT elfFullName AS STRING * LF_FULLFACESIZE elfStyle AS STRING * LF_FACESIZE END TYPE DECLARE FUNCTION WinMain (byval hInstance as long, _ byval hPrevInstance as long, _ szCmdLine as string, _ byval iCmdShow as long) as long 'entry point DIM Shared hInst AS LONG hInst=GetModuleHandle(null) END WinMain(hInst, null, Command$, SW_NORMAL) SUB RoundRectangle (BYVAL hDC AS uinteger, BYVAL x AS LONG, BYVAL y AS LONG, _ BYVAL x2 AS LONG, BYVAL y2 AS LONG, BYVAL rw AS LONG, _ BYVAL rh AS LONG, BYVAL BrushPattern AS LONG, _ BYVAL BrushClr AS LONG, BYVAL PenType AS LONG, _ BYVAL PenWidth AS LONG, BYVAL PenClr AS LONG) DIM hBrush AS uinteger, hPen AS uinteger hPen = CreatePen(PenType, PenWidth, PenClr) ' create pen with given color hPen = SelectObject(hDC, hPen) ' select it into given dc IF BrushPattern = 0 THEN hBrush = CreateSolidBrush(BrushClr) ' create solid brush with given color ELSE hBrush = CreateHatchBrush(BrushPattern, BrushClr) ' create hatched brush with given color END IF hBrush = SelectObject(hDC, hBrush) ' select it into given dc RoundRect hDC, x, y, x2, y2, rw, rh ' draw the actual rectangle DeleteObject SelectObject(hDC, hBrush) ' delete what we created DeleteObject SelectObject(hDC, hPen) ' to avoid memory leaks END SUB FUNCTION EnumCharSet(elf AS ENUMLOGFONT,ntm AS NEWTEXTMETRIC, _ BYVAL FontType AS LONG,CharSet AS LONG) AS LONG CharSet = elf.elfLogFont.lfCharSet END FUNCTION FUNCTION MakeFontEx(sFont AS STRING, BYVAL PointSize AS LONG, _ BYVAL fBold AS LONG, BYVAL fItalic AS LONG, BYVAL fUnderline AS LONG, _ BYVAL StrikeThru AS LONG) AS LONG DIM hDC AS LONG, CharSet AS LONG, CyPixels AS LONG hDC = GetDC(HWND_DESKTOP) CyPixels = GetDeviceCaps(hDC, LOGPIXELSY) EnumFontFamilies(hDC, BYVAL sFont, @EnumCharSet , BYVAL CharSet) ReleaseDC(HWND_DESKTOP, hDC) PointSize = 0 - (PointSize * CyPixels) \ 72 MakeFontEx = CreateFont(PointSize,0,0,0, fBold, _ fItalic,fUnderline,StrikeThru,CharSet, _ OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS, _ DEFAULT_QUALITY,FF_DONTCARE, _ sFont) END FUNCTION DATA "Rec. Nr.", 80, "Last Name", 120, "First Name", 120," Phone", 120, "Email", 120 DATA "101", "Boggs", "Jimmy", "(532) 223-3034","jboggs@aol.com" DATA "102", "Smith", "Granny", "(244) 545-8970","gsmith@msn.com" DATA "103", "Washington"," Roy","(434) 677-1432","rwash@pldi.net" DATA "104", "James", "Frank","(439) 879-5468","james@excite.com" FUNCTION ProcessWindow (BYVAL hDlg AS Uinteger, BYVAL wMsg AS Uinteger, BYVAL wParam _ AS Uinteger, BYVAL lParam AS LONG) AS LONG STATIC hLBbrush1 AS LONG STATIC hEDbrush1 AS LONG STATIC hBmp1 AS LONG STATIC hBmp3 AS LONG STATIC hBmp4 AS LONG STATIC hBmp5 AS LONG STATIC hLv1 AS LONG STATIC hLv2 AS LONG STATIC hLv3 AS LONG STATIC hLv4 AS LONG DIM MemDC1 AS LONG, rc1 AS RECT, bm1 AS BITMAP DIM MemDC3 AS LONG, rc3 AS RECT, bm3 AS BITMAP DIM MemDC4 AS LONG, rc4 AS RECT, bm4 AS BITMAP DIM MemDC5 AS LONG, rc5 AS RECT, bm5 AS BITMAP DIM LvItm1 AS LV_ITEM , LVcol1 AS LV_COLUMN DIM LvItm2 AS LV_ITEM , LVcol2 AS LV_COLUMN DIM LvItm3 AS LV_ITEM , LVcol3 AS LV_COLUMN DIM LvItm4 AS LV_ITEM , LVcol4 AS LV_COLUMN DIM ps AS PAINTSTRUCT DIM xl AS LONG, yl AS LONG, xx AS LONG, lStyle AS LONG DIM ff AS LONG, Length AS LONG, Index AS LONG, x AS LONG DIM wmID AS LONG, wmEvent AS LONG, eFgColor1 AS LONG DIM eBgColor1 AS LONG, hCtrl AS LONG, hRich1 AS LONG DIM hfont AS LONG, hHand AS LONG, LBgColor1 AS LONG DIM LFgColor1 AS LONG, check AS LONG DIM row AS SINGLE DIM Buff1 AS string * 14 DIM Buf1 AS string * 14 DIM Buf2 AS string * 16 DIM Buf3 AS string * 16 DIM Buf4 AS string * 80 DIM EdTxt1 AS STRING * 40 DIM RichTxt1 AS STRING * 80 DIM itm AS STRING DIM CbText1 AS STRING DIM LbText1 AS STRING DIM MSBtx AS STRING DIM Lt1 AS STRING DIM Lt2 AS STRING DIM Et3 AS STRING DIM Lt4 AS STRING LBgColor1 = &HB8E989 ' Selected background color for ListBox1 LFgColor1 = &H400080 ' Selected foreground color for ListBox eFgColor1 = &HECFFCE ' Selected foreground color for Edit eBgColor1 = &H301983 ' Selected background color for Edit IF wMsg = WM_CREATE THEN ' Messages that Initializes Controls and ' tasks that affects the Appearance of Dialogs hLBbrush1 = CreateSolidBrush(LBgColor1) ' Creates a logical brush with specified color for ListBox1 hEDbrush1 = CreateSolidBrush(eBgColor1) ' Creates a brush with the specified color hBmp1 = LoadImage(0, "sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) hBmp3 = LoadImage(0, "sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) GetObject(hBmp3, LEN(bm3), bm3) ' get bitmap's size hBmp4 = LoadImage(0, "sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) hBmp5 = LoadImage(0, "sonya15.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE) GetObject(hBmp5, LEN(bm5), bm5) ' get bitmap's size DIM ARay3(5,5) AS STRING Aray3(0,0)="101" : ARay3(0,1)="Boggs" : ARay3(0,2)="Jimmy" Aray3(0,3)="(532) 223-3034" : ARay3(0,4)="jimmyb@aol.com" Aray3(1,0)="102" : ARay3(1,1)="Bullard" : ARay3(1,2)="Lester" Aray3(1,3)="(361) 893-5792" : ARay3(1,4)="lbull@msn.com" Aray3(2,0)="103" : Aray3(2,1)="Sprite": ARay3(2,2)="Jack" ARay3(2,3)="(580) 935-7242" : Aray3(2,4)="Jsprit@pldi.net" Aray3(3,0)="104" : ARay3(3,1)="Williams" : Aray3(3,2)="Sandy" ARay3(3,3)="(303) 453-9087" : ARay3(3,4)="swil@excite.com" #DEFINE BTN_STYLES WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR BS_CENTER hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Check 1", _ BTN_STYLES OR _ BS_AUTOCHECKBOX, _ 670, 154, _ 100, 19, _ hdlg, 120, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Check 2", _ BTN_STYLES OR _ BS_AUTOCHECKBOX, _ 670, 198, _ 100, 19, _ hdlg, 121, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Check 3", _ BTN_STYLES OR _ BS_AUTOCHECKBOX, _ 670, 242, _ 100, 19, _ hdlg, 122, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Check 4", _ BTN_STYLES OR _ BS_AUTOCHECKBOX OR _ BS_PUSHLIKE, _ 670, 286, _ 100, 19, _ hdlg, 123, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ 0, _ "Button", _ "Check 5", _ BTN_STYLES OR _ BS_AUTOCHECKBOX OR _ BS_FLAT OR _ BS_PUSHLIKE, _ 670, 330, _ 100, 19, _ hdlg, 124, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Option 1", _ BTN_STYLES OR _ BS_AUTORADIOBUTTON, _ 10, 154, _ 100, 19, _ hdlg, 125, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Option 2", _ BTN_STYLES OR _ BS_AUTORADIOBUTTON, _ 10, 198, _ 100, 19, _ hdlg, 126, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Option 3", _ BTN_STYLES OR _ BS_AUTORADIOBUTTON OR _ BS_PUSHLIKE, _ 10, 242, _ 100, 19, _ hdlg, 127, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ WS_EX_ClientEdge, _ "Button", _ "Option 4", _ BTN_STYLES OR _ BS_AUTORADIOBUTTON OR _ BS_PUSHLIKE, _ 10, 286, _ 100, 19, _ hdlg, 128, _ hInst, BYVAL NULL _ ) hCtrl = CreateWindowEx _ ( _ 0, _ "Button", _ "Option 5", _ BTN_STYLES OR _ BS_AUTORADIOBUTTON OR _ BS_FLAT OR _ BS_PUSHLIKE, _ 10, 330, _ 100, 19, _ hdlg, 129, _ hInst, BYVAL NULL _ ) hFont = MakeFontEx("Microsoft Sans Serif", -12, 700, 1, 0, 0) ' Get a Handle for this Font hHand = GetDlgItem(hDlg, 110) ' Get Handle for a Control using its ID nr and its Parent Handle CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE) ' Change font in Control using its handle and Font handle Lt1=Lt1 + "" hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT1 ), _ SS_BITMAP OR WS_CHILD OR WS_VISIBLE, _ 240, 1, 100, 129, _ hdlg, 103, hInst, BYVAL NULL) Lt2=Lt2 + "" hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT2 ), _ SS_BITMAP OR WS_CHILD OR WS_VISIBLE, _ 430, 1, 100, 129, _ hdlg, 104, hInst, BYVAL NULL) Lt4=Lt4 + "This is the Label control, unless you change the " Lt4=Lt4 + "background color, it will be window color. Text can be " Lt4=Lt4 + "changed also, plus bitmap can be added." hCtrl = CreateWindowEx(0, "static", BYVAL STRPTR( LT4 ), _ WS_CHILD OR WS_VISIBLE, _ 544, 418, 220, 107, _ hdlg, 114, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "&Retry", _ WS_CHILD OR WS_VISIBLE OR BS_OWNERDRAW , _ 240, 418, 100, 131, _ hdlg, 105, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "", _ WS_CHILD OR WS_VISIBLE OR BS_BITMAP , _ 430, 418, bm5.bmWidth, bm5.bmHeight, _ hdlg, 106, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "Button", "&Ok", _ WS_CHILD OR WS_VISIBLE OR BS_PUSHBUTTON, _ 370, 528, 45, 21, _ hdlg, 115, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Edit", "", _ WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR ES_LEFT OR _ ES_MULTILINE OR ES_WANTRETURN, _ 10, 22, 210, 107, _ hdlg, 111, hInst, BYVAL NULL) Et3=Et3 + "This is the Read Only Edit control, You can't type in this " hCtrl = CreateWindowEx(WS_EX_ClientEdge, "Edit", Et3, _ WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR ES_LEFT OR _ ES_MULTILINE OR ES_WANTRETURN OR ES_READONLY, _ 10, 418, 210, 107, _ hdlg, 113, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "ComboBox", "", _ WS_CHILD OR WS_TABSTOP OR WS_VISIBLE OR CBS_DROPDOWN OR _ CBS_AUTOHSCROLL OR CBS_HASSTRINGS, _ 350, 1, 70, 503, _ hdlg, 101, hInst, BYVAL NULL) hCtrl = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", _ WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR WS_BORDER OR _ WS_VSCROLL OR LBS_NOTIFY OR LBS_HASSTRINGS , _ 350, 44, 60, 440, _ hdlg, 102, hInst, BYVAL NULL) hLv1 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _ WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ LVS_SHOWSELALWAYS OR LVS_NOSORTHEADER OR LVS_REPORT OR _ LVS_SINGLESEL, _ 150, 154, 170, 92, _ hdlg, 107, hInst, BYVAL NULL) hLv2 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _ WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ LVS_SHOWSELALWAYS OR LVS_NOSORTHEADER OR LVS_REPORT OR _ LVS_SINGLESEL, _ 150, 286, 170, 92, _ hdlg, 108, hInst, BYVAL NULL) hLv3 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _ WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ LVS_SHOWSELALWAYS OR LVS_NOSORTHEADER OR LVS_REPORT OR _ LVS_SINGLESEL, _ 450, 154, 190, 92, _ hdlg, 109, hInst, BYVAL NULL) hLv4 = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", "", _ WS_GROUP OR WS_VISIBLE OR WS_CHILD OR WS_BORDER OR _ LVS_SHOWSELALWAYS OR LVS_NOSORTHEADER OR LVS_REPORT OR _ LVS_SINGLESEL, _ 450, 286, 190, 92, _ hdlg, 110, hInst, BYVAL NULL) LoadLibrary("RICHED32.DLL") hRich1 = CreateWindowEx(WS_EX_CLIENTEDGE, "RichEdit", "RichEdit", _ WS_CHILD OR WS_VISIBLE OR WS_CHILD OR WS_VISIBLE OR _ WS_TABSTOP OR WS_VSCROLL OR ES_WANTRETURN OR _ ES_AUTOVSCROLL OR ES_MULTILINE OR ES_NOHIDESEL OR _ ES_SAVESEL OR ES_DISABLENOSCROLL, _ 540, 22, 230, 110, _ hDlg, 112, hInst, BYVAL NULL) SendMessage hRich1, EM_SETSEL, 1, 1 ' to reset pos/selection in text SendMessage hRich1, EM_SCROLLCARET, 0, 0 ' Make caret scroll into view.. SendMessage hRich1, EM_SETOPTIONS, ECOOP_OR, ECO_SELECTIONBAR SendMessage hRich1, EM_SETMARGINS, EC_LEFTMARGIN, 5 ' Set Left Margin SetWindowText hRich1, "Included are some SendMessages for RichEdit" SendMessage GetDlgItem(hDlg, 104), STM_SETIMAGE, IMAGE_BITMAP, BYVAL hBmp3 SendMessage GetDlgItem(hDlg, 106),BM_SETIMAGE,IMAGE_BITMAP, BYVAL hBmp5 hCtrl = GetDlgItem(hDlg, 101) ' Get Handle of Control, using handle of Dialog FOR x = 0 TO 22 ' Load ComboBox with Items to select itm = "Item" + STR$(x) ' Create an Item using that string SendMessage(hCtrl, CB_ADDSTRING, 0, BYVAL itm) ' Put the Item in the ComboBox for display NEXT X hCtrl = GetDlgItem(hDlg, 102) FOR x = 1 TO 20 ' Load ListBox with Items to select itm = "Item" + STR$(x) ' Create an Item using that string SendMessage(hCtrl, LB_ADDSTRING, 0, BYVAL itm) ' Put the Item in the ListBox for display NEXT X hFont = MakeFontEx("Times New Roman", -13, 700, 0, 0, 0) ' Get a Handle for this Font hHand = GetDlgItem(hDlg, 101) ' Get Handle for a Control using its ID nr and its Parent Handle CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE) ' Change font in Control using its handle and Font handle hFont = MakeFontEx("Cooper BlkIt BT", -15, 400, 0, 0, 0) ' Get a Handle for this Font hHand = GetDlgItem(hDlg, 102) ' Get Handle for a Control using its ID nr and its Parent Handle CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE) ' Change font in Control using its handle and Font handle hFont = MakeFontEx("Microsoft Sans Serif", -11, 700, 0, 0, 0) ' Get a Handle for this Font hHand = GetDlgItem(hDlg, 111) ' Get Handle for a Control using its ID nr and its Parent Handle CALL SendMessage(hHand, WM_SETFONT, hfont, TRUE) ' Change font in Control using its handle and Font handle SetWindowPos hDlg, HWND_TOP, 0, 0, 0, 0, SWP_NoSize OR SWP_NoMove lStyle = SendMessage(hLv1, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lStyle = lStyle OR LVS_EX_GRIDLINES OR LVS_EX_FULLROWSELECT SendMessage(hLv1, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle) LVcol1.psztext=VARPTR(Buf1) LVcol1.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM FOR xl = 1 TO 5 ' For/Next to create header Buf1 = "Column " + STR$(xl) ' assign column name LVcol1.cx= 72 ' assign GUI column width LVcol1.isubitem=xl ' column number SendMessage hLv1, LVM_INSERTCOLUMN, xl, LVcol1 ' Send it to LV NEXT xl xl = 1 : ff = FREEFILE ' filenumber for creating & saving filler Data to file OPEN ".\LLLVVVX1.ZZZ" FOR BINARY AS #ff FOR yl=1 TO 20 buff1="Item Nr" + STR$(xl) ' Create Item filler Data for buffer PUT #ff,seek(ff), buff1 ' Write column 1 filler DATA to file FOR xx = 1 TO 4 buff1="Item Nr"+STR$(xx*100+xl) PUT #ff, SEEK(ff), buff1 ' Write the rest to file NEXT xx xl=xl+1 NEXT yl CLOSE ff LvItm1.mask=LVIF_TEXT ' flag that specifies text LvItm1.psztext=VARPTR(Buf1) ' Pointer to buffer xl = 0 : ff = FREEFILE ' for filler DATA from file to LV OPEN ".\LLLVVVX1.ZZZ" FOR BINARY AS #ff FOR yl=1 TO 20 GET #ff, SEEK(ff), buf1 ' get first column item from file LvItm1.iitem=xl ' line number LvItm1.isubitem=0 ' number for column 1 subitem SendMessage hLv1, LVM_INSERTITEM, 0, LvItm1 FOR xx = 1 TO 4 LvItm1.isubitem=xx ' number for rest of items GET #ff, SEEK(ff), buf1 ' get the rest of the items SendMessage(hLv1, LVM_SETITEMTEXT, xl, LvItm1) ' send items to LV NEXT xx xl=xl+1 NEXT yl CLOSE #FF lStyle = SendMessage(hLv2, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lStyle = lStyle OR LVS_EX_GRIDLINES OR LVS_EX_FULLROWSELECT SendMessage(hLv2, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle) LVcol2.psztext=VARPTR(Buf2) LVcol2.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM RESTORE FOR xl = 0 TO 8 ' Setup to read Data for columns READ Buf2 ' read column name READ LVcol2.cx ' read column GUI width LVcol2.isubitem=xl/2 ' Setup for sending to LV SendMessage(hLv2, LVM_INSERTCOLUMN, xl/2, LVcol2) ' Send to LV xl=xl+1 NEXT xl xl=0 LvItm2.mask=LVIF_TEXT LvItm2.psztext=VARPTR(Buf2) FOR row=11 TO 30 STEP 5 ' Setup to Read from DATA LvItm2.iitem=xl ' line number LvItm2.isubitem=0 ' number for column 1 subitem READ buf2 SendMessage hLv2, LVM_INSERTITEM, xl, LvItm2 FOR yl = 1 TO 4 LvItm2.isubitem = yl ' number for rest of items READ buf2 ' Read the rest of the items and SendMessage(hLv2, LVM_SETITEMTEXT, xl, LvItm2) ' Send them to LV NEXT yl xl=xl+1 NEXT lStyle = SendMessage(hLv3, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lStyle = lStyle OR LVS_EX_GRIDLINES OR LVS_EX_FULLROWSELECT SendMessage(hLv3, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle) LVcol3.psztext=VARPTR(Buf3) LVcol3.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM RESTORE FOR xl = 0 TO 8 ' Setup to read Data for columns READ Buf3 ' read column name READ LVcol3.cx ' read column GUI width LVcol3.isubitem=xl/2 ' Setup for sending to LV SendMessage(hLv3, LVM_INSERTCOLUMN, xl/2, LVcol3) ' Send to LV xl=xl+1 NEXT xl xl=0 LvItm3.mask=LVIF_TEXT LvItm3.psztext=VARPTR(Buf3) FOR row=0 TO 3 LvItm3.iitem=xl ' line number LvItm3.isubitem=0 ' number for column 1 subitem buf3 = Aray3(row, 0) ' Fill buffer with item from array SendMessage hLv3, LVM_INSERTITEM, xl, LvItm3 ' Send it to LV FOR yl = 1 TO 4 ' Do rest of the items LvItm3.isubitem = yl buf3 = Aray3(row,yl) SendMessage hLv3, LVM_SETITEMTEXT, xl, LvItm3 NEXT yl xl=xl+1 NEXT lStyle = SendMessage(hLv4, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lStyle = lStyle OR LVS_EX_GRIDLINES OR LVS_EX_FULLROWSELECT SendMessage(hLv4, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, BYVAL lStyle) LVcol4.psztext=VARPTR(Buf4) LVcol4.mask=LVCF_TEXT OR LVCF_WIDTH OR LVCF_SUBITEM Buf4 = "This is the header text for the listview" LVcol4.cx= 380 ' gui column width LVcol4.isubitem= 1 ' Column number SendMessage(hLv4, LVM_INSERTCOLUMN, xl, LVcol4) xl=1 LvItm4.mask=LVIF_TEXT ' flag that specifies text LvItm4.psztext=VARPTR(Buf4) ' Point to buffer FOR yl = 1 TO 20 ' number of lines to display buf4="Record Nr" + STR$(yl)+" " + STRING$(50,"X")' Create text for LV LvItm4.iitem=yl ' get Line number SendMessage(hLv4, LVM_INSERTITEM, 0, LvItm4) ' Send it to LV NEXT yl ELSEIF wMsg = WM_CTLCOLORSTATIC THEN IF LPARAM = GetDlgItem(hDlg, 103) AND hBmp1 THEN GetClientRect LPARAM, rc1 'label's size GetObject hBmp1, LEN(bm1), bm1 'get bitmap's size MemDC1 = CreateCompatibleDC(WPARAM) 'create DC for bitmap SelectObject MemDC1, hBmp1 'select bitmap into DC, then paint it to label's dc StretchBlt WPARAM, 0, 0, rc1.nRight, rc1.nBottom, _ MemDC1, 0, 0, bm1.bmWidth, bm1.bmHeight, SRCCOPY 'stretched to control DeleteDC MemDC1 'clean up temporary DC ProcessWindow = GetStockObject(HOLLOW_BRUSH) 'return a hollow brush END IF ELSEIF wMsg = WM_CTLCOLORBTN THEN IF LPARAM = GetDlgItem(hDlg, 105) AND hBmp4 THEN GetClientRect LPARAM, rc4 'label's size GetObject hBmp4, LEN(bm4), bm4 'get bitmap's size MemDC4 = CreateCompatibleDC(WPARAM) 'create DC for bitmap SelectObject MemDC4, hBmp4 'select bitmap into DC, then paint it to label's dc StretchBlt WPARAM, 0, 0, rc4.nRight, rc4.nBottom, _ MemDC4, 0, 0, bm4.bmWidth, bm4.bmHeight, SRCCOPY 'stretched to control DeleteDC MemDC4 'clean up temporary DC ProcessWindow = GetStockObject(HOLLOW_BRUSH) 'return a hollow brush END IF ELSEIF wMsg = WM_CTLColorEdit THEN ' Message to color an Edit Control IF GetDlgCtrlId(lParam) = 111 THEN ' Check its ID number SetTextColor Wparam, eFgColor1 ' Set the Forground Color SetBkColor Wparam, eBgColor1 ' Set the BackGround Color ProcessWindow = hEDbrush1 : EXIT FUNCTION END IF ELSEIF wMsg = WM_CTLColorListBox THEN ' Message to color a ListBox IF GetDlgCtrlId(lParam) = 102 THEN ' Check its ID number SetTextColor Wparam, LFgColor1 ' Set the Forground to selected Color SetBkColor Wparam, LBgColor1 ' Set the BackGround to selected Color ProcessWindow = hLBbrush1 : EXIT FUNCTION END IF ELSEIF wMsg = WM_DESTROY THEN ' Message sent when a Window is being destroyed DeleteObject hLBbrush1 ' Frees all system resources associated with this brush DeleteObject hBmp1 DeleteObject hBmp3 DeleteObject hBmp4 DeleteObject hBmp5 DeleteObject hEDbrush1 ' Frees all system resources associated with this brush ELSEIF wMsg = WM_COMMAND THEN ' Messages sent for Command Items wmID = wParam and &hFFFF ' Control ID wmEvent = wParam shr 16 ' Window Event ' a control sends notification messages to its Parent IF wmEvent = BN_CLICKED THEN ' Intercept a Mouse click IF wmID = 105 THEN ' Retry Button MessageBox GetActiveWindow(), " Retry Button"," ", 0 OR MB_TASKMODAL ELSEIF wmID = 106 THEN MessageBox GetActiveWindow(), " Retry Button"," ", 0 OR MB_TASKMODAL ELSEIF wmID = 115 THEN GetWindowText(GetDlgItem(hDlg, 111), EdTxt1, LEN(EdTxt1)) ' Put Edit Controls Text in a String MsbTx = msbTx + EdTxt1 + CHR$(13)+CHR$(10) GetWindowText(GetDlgItem(hDlg, 112), RichTxt1, LEN(RichTxt1)) ' Put Edit Controls Text in a String hCtrl = GetDlgItem( hDlg, 120) ' Get CheckBox Handle using its ID number and Parent Handle check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Check if this Checkbox is checked IF check THEN MSBtx=MSBtx + " CheckBox nr1 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem( hDlg, 121) ' Get CheckBox Handle using its ID number and Parent Handle check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Check if this Checkbox is checked IF check THEN MSBtx=MSBtx + " CheckBox nr2 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem( hDlg, 122) ' Get CheckBox Handle using its ID number and Parent Handle check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Check if this Checkbox is checked IF check THEN MSBtx=MSBtx + " CheckBox nr3 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem( hDlg, 123) ' Get CheckBox Handle using its ID number and Parent Handle check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Check if this Checkbox is checked IF check THEN MSBtx=MSBtx + " CheckBox nr4 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem( hDlg, 124) ' Get CheckBox Handle using its ID number and Parent Handle check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Check if this Checkbox is checked IF check THEN MSBtx=MSBtx + " CheckBox nr5 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem(hDlg, 125) ' Get Control Handle using dialog handle and Control ID check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Use handle to see if RadioButton is checked IF check THEN MSBtx=MSBtx + " RadioButton nr 1 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem(hDlg, 126) ' Get Control Handle using dialog handle and Control ID check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Use handle to see if RadioButton is checked IF check THEN MSBtx=MSBtx + " RadioButton nr 2 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem(hDlg, 127) ' Get Control Handle using dialog handle and Control ID check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Use handle to see if RadioButton is checked IF check THEN MSBtx=MSBtx + " RadioButton nr 3 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem(hDlg, 128) ' Get Control Handle using dialog handle and Control ID check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Use handle to see if RadioButton is checked IF check THEN MSBtx=MSBtx + " RadioButton nr 4 was checked" + CHR$(13)+CHR$(10) hCtrl = GetDlgItem(hDlg, 129) ' Get Control Handle using dialog handle and Control ID check = SendMessage(hCtrl, BM_GetCheck, 0, 0) ' Use handle to see if RadioButton is checked IF check THEN MSBtx=MSBtx + " RadioButton nr 5 was checked" + CHR$(13)+CHR$(10) MessageBox GetActiveWindow(), BYVAL STRPTR(msbTX), "", MB_OK PostQuitMessage 0 'off switch END IF END IF IF wmID = 101 AND wmEvent = CBN_SELCHANGE THEN ' Message sent to Parent thru WM_COMMAND when ComboBox Item is clicked hCtrl = GetDlgItem( hDlg, 101 ) ' Get Handle of Control, using handle of Dialog Index = SendMessage( hCtrl, CB_GETCURSEL, 0, 0 ) ' Get Index of the currently selected Item Length = SendMessage( hCtrl, CB_GETLBTEXTLEN, Index, 0 ) ' Get text length of selected Item IF Length < 1 THEN EXIT FUNCTION CbText1 = STRING$( Length, 0 ) ' Create Buffer in string that will hold the text SendMessage hCtrl, CB_GETLBTEXT, Index, BYVAL STRPTR( CbText1 ) ' Put selected text in the string CbText1 = "ComboBox Nr1"+ CHR$(32) + CbText1 ' String used in Example PBMAIN displaying item selected MessageBox GetActiveWindow(),BYVAL STRPTR( CbText1 ),"You Clicked on", MB_OK ' MessageBox showing which Item selected END IF IF wmID = 102 AND wmEvent = LBN_SELCHANGE THEN ' Message sent to Parent thru WM_COMMAND when ListBox Item is clicked hCtrl = GetDlgItem( hDlg, 102 ) ' Get Handle of Control, using handle of Dialog Index = SendMessage( hCtrl, LB_GETCURSEL, 0, 0 ) Length = SendMessage( hCtrl, LB_GETTEXTLEN, Index, 0 ) ' Get text length of selected Item IF Length < 1 THEN EXIT FUNCTION LbText1 = STRING$( Length, 0 ) ' Create Buffer in string that will hold the text SendMessage hCtrl, LB_GETTEXT, Index, BYVAL STRPTR( LbText1 ) ' Put selected text in the string LbText1 = "ListBox Nr1"+ CHR$(32) + LbText1 ' String used in Example PBMAIN displaying item selected MessageBox GetActiveWindow(),BYVAL STRPTR( LbText1 ),"You Clicked on", MB_OK ' MessageBox showing which Item selected END IF ELSEIF wMsg = WM_PAINT THEN ' dialog is to be redrawn BeginPaint hDlg, ps ' get device context to draw in RoundRectangle(ps.hDC, 20, 22, 751, 525, 731, 503, _ HS_DIAGCROSS , &HC0C0C0, PS_NULL , 1, 0) RoundRectangle(ps.hDC, 130, 132, 331, 415, 20, 20, _ HS_BDIAGONAL , &H808080, PS_SOLID, 3, &HC0C0C0) RoundRectangle(ps.hDC, 430, 132, 651, 415, 20, 20, _ HS_FDIAGONAL , &H808080, PS_SOLID, 1, 0) EndPaint hDlg, ps ' end painting ELSEIF wMsg = WM_CLOSE THEN ' Message from Clicking on system close Icon PostQuitMessage 0 END IF ProcessWindow = DefWindowProc(hdlg, wMsg, wParam, lParam) END FUNCTION FUNCTION WINMAIN (BYVAL hInstance AS LONG, _ BYVAL hPrevInstance AS LONG, _ szCmdLine AS STRING, _ BYVAL iCmdShow AS LONG) AS LONG DIM wMsg AS Msg DIM wcls AS wndclass DIM hWnd AS unsigned LONG DIM szpgmname AS STRING, style as long InitCommonControls szpgmname = "FreeBasic GUI Samples" WITH wcls .style = CS_HREDRAW OR CS_VREDRAW OR CS_DBLCLKS .lpfnWndProc = @ProcessWindow 'point to callback code .cbClsExtra = 0 .cbWndExtra = 0 .hInstance = hInstance .hIcon = LoadIcon( hInstance, "MAINICON" ) .hCursor = LoadCursor( NULL, BYVAL IDC_ARROW ) .hbrBackground = GetStockObject(WHITE_BRUSH ) .lpszMenuName = NULL .lpszClassName = STRPTR(szpgmname) END WITH RegisterClass wcls style = WS_VISIBLE OR WS_OVERLAPPEDWINDOW OR DS_MODALFRAME hWnd = CreateWindowEx(0, szpgmname, "Regular SDK Example", _ Style, 0, 0, 790, 583, _ HWND_DESKTOP, NULL, hInstance, BYVAL NULL) WHILE (GetMessage(wMsg, NULL, 0, 0) <> false ) TranslateMessage wMsg DispatchMessage wMsg WEND WinMain = wMsg.wParam END FUNCTION [/syntax] Hope it works on Win98 too...
= inc(¢)
03-31-2005, 06:22 PM
Your source does not work on my win98se, but FB v0.13(cvs) does. Here is the error msg. Yes ,there is sonya15.bmp:
Quote:TEST the module at 019f:0040112c |
« Next Oldest | Next Newest »
|
Users browsing this thread: 1 Guest(s)