• Welcome to PlanetSquires Forums.
 

CWindow RC05

Started by José Roca, May 02, 2016, 07:21:53 PM

Previous topic - Next topic

Paul Squires

Quote from: Jose Roca on May 04, 2016, 06:25:27 PM
> I have also been testing the use of message crackers and dedicated message handlers.

For what I see, these aren't needed in CWindow or the custom controls. You can freely use them in your code if you like. Am I right?


Yes, you are right.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

No problem then. I understand is usefulness for a visual designer, to no overwrite the message processing in the window procedure, but when coding by hand as I always do, when there is code that is going to be too long you simply put it in a procedure and call it. A manual and selective way of message cracking.

José Roca

I have to recheck all the code removing #define unicode. Even calling the W function, something like this LoadCursorW(NULL, IDC_ARROW) compiles fine using #define unicode and reports an error if not. I will have to add more CASTs.

José Roca

Well, looks like that one was the only that needed a change.

Paul Squires

Just a little FYI for you in case you don't know.... In FB if you ever want to see the exact code that will be compile (macros expanded, etc) then just pass -pp to the compiler. It will create an intermediate file with ".pp" appended to it. It can be quite useful sometimes.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

I posted that array passing and copying issue over on the FB forum. I am very curious as to why it does not work.
http://www.freebasic.net/forum/viewtopic.php?f=6&t=24667
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

#36
Thanks for the tip and the support. I have run several test programs removing the unicode define and the only problems that have found are LoadCursorW in CWindows, and a CreateFontIndirect (I forgot to add the "W") in the XpButton and PgBar3D controls.

Will write all the upcoming code without #define unicode to avoid these failures.

Paul Squires

FYI,

fxm responded to the fixed WSTRING array issue:  http://www.freebasic.net/forum/viewtopic.php?f=6&t=24667#p219838
It is a known problem.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

Hi Jose,

Looking at the examples that you have posted, I see that you use GetModuleHandle with an empty string for the parameter. This seems to always return 0 indicating an error. I read the api docs and I think you are better off using Null instead of an empty string?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683199(v=vs.85).aspx

   End WinMain(GetModuleHandleW(Null), Null, Command(), SW_NORMAL)

Using Null, I am getting a value returned for the hInstance.


Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Thanks very much. I will remember it.

José Roca

Hi Paul,

I have read that unused Private procedures are removed by the compiler.

> fbc already removes unused private procedures/variables, but that's pretty much it.
See: http://www.freebasic.net/forum/viewtopic.php?t=23405

Could be this a solution to write wrapper procedures without adding bloat?

José Roca

It works!

I wonder why they don't explain it in the documentation.

José Roca

#42
Another oddity.

This works:


DIM tbb AS TBBUTTON = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)


But this one gives Error 7: Expected ')'


DIM tbb AS TBBUTTON
tbb = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)



Paul Squires

Quote from: Jose Roca on May 05, 2016, 04:18:57 PM
Another oddity.

This works:


DIM tbb AS TBBUTTON = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)


But this one gives Error 7: Expected ')'


DIM tbb AS TBBUTTON
tbb = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)


More than likely it has to do with the code generation of each compiler version. By default, FBC 32bit outputs ASM code that is then compiled by the GNU assembler. FBC 64bit defaults to outputting C code that is then compiled with gcc (llvm eventually will be fully supported).

You can see the intermediate code generated (ASM or C) when you specify the -r command line option for the compiler.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

José Roca

Sorry, but you have misunderstood me.

This one works both in 32 and 64 bit:


#ifdef __FB_64BIT__
   DIM tbb AS TBBUTTON = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)
#else
   DIM tbb AS TBBUTTON = (idxBitmap, idCommand, fsState, fsStyle, {0, 0}, dwData, idxString)
#endif


But if I dim tbb separately and then I try to do the assignment, it fails:


#ifdef __FB_64BIT__
   DIM tbb AS TBBUTTON
   tbb = (idxBitmap, idCommand, fsState, fsStyle, {0, 0, 0, 0, 0, 0}, dwData, idxString)
#else
   DIM tbb AS TBBUTTON
   tbb = (idxBitmap, idCommand, fsState, fsStyle, {0, 0}, dwData, idxString)
#endif