Windows C++ GUI

Pages: 123

Hi Fred,
I do have a DropBox Account I didn't think of uploading the entire project as I can tell that you are not impressed with VStudio!


I do have Visual Studio 2015 Community and I gather a DropBox account becomes available with that somehow. I ought to look into it and see if I can't set it up. That sort of thing does really fill a need, as I'm sometimes bewildered as to how to get code to folks. Posting here is awkward due to the 8192 byte limit on posts. I've a board at my friend Jose Roca's site, but one would have to join to be able to use attachments. I've a gmail account but I don't believe binaries can be emailed, although possibly in zips. Yea, I wouldn't pay anything for Visual Studio, but I'd actually consider paying for storage at something like DropBox. I'll have to think about it.

Years ago when MS came out with the 'string safe' versions of the C Runtime character string primitives (strcpy, strcat, strlen, etc.) I made a concerted effort to use them especially in code I post online. However, I had nothing but troubles. Don't know why. Finally I did a search on it and found out there were bugs or something in the implementations. Everything was crashing all the time when I used them. So I threw up my hands in dispair and said 'the h*** with it. I tried'.

Post back when you get back to it. I'm sure folks, including me, will try to help!
@freddie,

dropbox gives you 2GB of free storage.
Gmail doesn't allow executables in zip files either.
Hi Freddie,
I'm really sorry but I have not been able to find my way around your code yet and I am getting pressed for a result.

Therefore I think that what I should do to start with is have one form with a couple of sections so that I can add a few text boxes and edit boxes that I can then set and get values to/from to allow me to calculate the parameters to send to the motor controller and to store in the csv file along with the retrieved data. My previous Windows programs were not as sophisticated as yours is and just used the long switch statement method.

Can you recommend somewhere that tells me what controls are available and how to create and use them please?

Ian
Basically, I'd say there are three broad 'classes' of controls, i.e., widgets in *nix speak, that can be used in SDK style Win32/64 projects.

First would be the 'standard' Windows controls such as text boxes (edit controls), labels (static controls), list boxes, combo boxes, etc. These are all created with CreateWindow() or CreateWindowEx().

Next in complexity and fanciness are the 'Common Controls' such as the Tab Control we used in your project. Others are the listview control, calander control, progress bar, etc. They are also created with CreateWindow() but one must first register the Common Control Class with that InitCommControlsEx() you had some difficulties with.

Lastly there are ActiveX Controls which are created within a client app with various OLE/COM apis (internally, CreateWindow() calls are occurring within the COM dlls).

Note that one never needs to create global/static variables for the HWNDs returned by CreateWindow() calls. The Menu ID / Control ID parameter of the CreateWindow call serves as a proxy for the HWND.

I'll get to your other questions in a bit. Gotta run now!

I've a couple minutes yet...

If you look back on Motor.cpp previously posted you'll see these lines in fnMotor_OnCreate() or whatever I named the function, which would correspond simply to what you would put in a WM_CREATE handler if switch logic was being used...

1
2
3
4
hCtl=CreateWindowEx(0,_T("static"),_T("Max Acceleration"),WS_CHILD|WS_VISIBLE,10,40,150,25,Wea.hWnd,(HMENU)-1,Wea.hInst,0);
 hCtl=CreateWindowEx(WS_EX_CLIENTEDGE,_T("edit"),_T(""),WS_CHILD|WS_VISIBLE,170,40,50,25,Wea.hWnd,(HMENU)IDC_MAX_ACCELERATION,Wea.hInst,0);
 hCtl=CreateWindowEx(0,_T("static"),_T("Max Speed"),WS_CHILD|WS_VISIBLE,10,80,100,25,Wea.hWnd,(HMENU)-1,Wea.hInst,0);
 hCtl=CreateWindowEx(0,_T("combobox"),_T(""),WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST|WS_VSCROLL,170,80,225,125,Wea.hWnd,(HMENU)IDC_MAX_SPEED2,Wea.hInst,0);


They are calls to create a couple labels and edit controls ('Standard Controls') on the first tab for the Motor Cobtrol.

Note the Api function call to retrieve text from controls is GetWindowText(). For that function you need the HWND of the control. If you look at my code above you'll note I threw them all away when I created them (tisk, tisk, tisk, wasteful me!). But you can get them at any point in the app with GetDlgItem(). That function requires the HWND of the control's parent and the 'Cobtrol ID' of the control when you created it. That's the proxy business I'm talking about. Its the HMENU / Control ID parameter of the CreateWindowEx call. For the edit control its IDC_MAX_ACCELERATION.
Last edited on
OK Thanks Freddie.

I'll take a look at that tomorrow morning .
Ian
I made a mistake above, Its GetDlgItem() not GetDlgCtrlId(). The latter is if you already have the HWND.
Topic archived. No new replies allowed.
Pages: 123