Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - HWND adding a Child Window

(you are viewing a thread; or go back to list of threads)

HWND adding a Child Window (by Roy)
Hi Jonathan

I want to add a Toolbar window to Ldmicro using the CreatewindowEx command. I have tried to add another variable hTool declared as a HWND but for some reason after I have compiled the project - it can't declare it as an HWND - instead it declares it as an INT as a default .


------ Build started: Project: ldmicro, Configuration: Debug Win32 ------
Compiling...
maincontrols.cpp
.\maincontrols.cpp(149) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\maincontrols.cpp(149) : error C2040: 'hTool' : 'int' differs in levels of indirection from 'HWND'
.\maincontrols.cpp(149) : error C2059: syntax error : ','
.\maincontrols.cpp(152) : error C2059: syntax error : 'if'
.\maincontrols.cpp(154) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Build log was saved at "file://c:\Program Files\Microsoft Visual Studio 9.0\VC\bin\ldmicro\Debug\BuildLog.htm"
ldmicro - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Is there something I have left out ?

Thanks
Roy
Fri Sep 17 2010, 08:50:24
(no subject) (by Jonathan Westhues)
You didn't post your code, but I would guess that you misspelled the name of whatever function you called. (Note that you misspelled CreateWindowEx in the post.) So there was no prototype in scope, and the compiler defaulted to int.
Fri Sep 17 2010, 09:20:17
(no subject) (by Roy)
Hi Jonathan


I have used code from an example and if I include

LRESULT CALLBACK WndProc(HWND MainWindow, UINT msg, WPARAM wParam, LPARAM lParam)

as part of the routine the I can compile the code however if I try to leave this out the int default error comes back. I don't see why I need the LRESULT CALLBACK and want to just make sure the toolbar appears on the screen - I am using standard icons at the moment but plan to make my own once I have got the toolbar to appear.

I am enclosing the code I am using for maincontrols.cpp

Thanks again
Roy.
Sat Sep 18 2010, 13:52:54, download attachment maincontrols.cpp
(no subject) (by Jonathan Westhues)
If the LRESULT CALLBACK... lines are commented out, then the calls to create the toolbar are not inside any function. This is not valid C or C++, so the compiler attempts to interpret the call as a function prototype. It isn't one, so this fails, with the default-int error.

If the lines are left in, then the code is still wrong. The callback function for a window processes messages delivered to that window (for example, when someone clicks on the window). These messages are delivered only after the window exists. So if the window is created only as a result of those messages, then it can be created only if it already exists, so it will never get created.

It might be a good idea to look at some of Microsoft's Win32 examples to start. They're much simpler than LDmicro, so it's easier to see what basic calls are necessary to create a window and process the resulting messages.
Mon Sep 20 2010, 00:44:38
USING BITMAP FILES (by Roy)
HI Jonathan

Thanks I managed to get it working. I am at the next objective which is to use bitmaps that I have created instead of the standard ones which I used initialy.
I have managed to create pictures.RESX file using the Resourcer program. This created a file which contains all the bitmap files.
I have also managed to include this into my program using the resource facility in Visual C++ . I can view the bitmap files using the resource viewer.

What I am trying to do at the moment is access these bitmap files in the program.

I saw an example where I was told to define the bitmaps as:
#define IDB_BTN0 3000

I will enclose the Ldmicro.cpp file . The Bitmaps are named Btn0.bmp , Btn1.bmp etc

I had everything working with the standard bitmaps My code is near the end of Ldmicro.


I can compile okay but can't see the bitmaps when I run the program

I am not sure if it is as simple as defining it with a number or there is more code needed. Do I need to refere to the resource file name somewhere ?

Thanks
Roy
Wed Sep 22 2010, 14:52:57, download attachment ldmicro.cpp
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):