Windows GUI

New to FreeBASIC? Post your questions here.
Provoni
Posts: 319
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Windows GUI

Postby Provoni » Nov 13, 2016 9:59

MichaelW wrote:GDI+ can do the conversion, Microsoft example here.
Sorry, no time to code an example.

Thanks and no problem. Haven't been able to look into it myself but the idea is to prevent a .bmp from being created in the first place.
Provoni
Posts: 319
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Windows GUI

Postby Provoni » Nov 13, 2016 10:03

There is another issue where the window is not being updated until the mouse is moved or another user action is taken. Does this perhaps have anything to do with the Windows message system and is there a way to send messages periodically?
MrSwiss
Posts: 3263
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Windows GUI

Postby MrSwiss » Nov 13, 2016 18:03

MichaelW Example (exerpt):

Code: Select all

hwnd = CreateWindowEx( 0, "test", "Test", WS_OVERLAPPED or WS_SYSMENU, _
                       0, 0, 0, 0, NULL, NULL, NULL, NULL )

ShowWindow( hwnd, SW_SHOWNORMAL )
UpdateWindow( hwnd )

do while GetMessage( @msg, NULL, 0, 0 ) > 0
    if IsDialogMessage(hwnd, @msg ) = 0 then
        TranslateMessage( @msg )
        DispatchMessage( @msg )
    end if
loop
If you stick the UpdateWindow( hwnd ) into the Loop, this should fix it.
Rewritten code portion:

Code: Select all

hwnd = CreateWindowEx( 0, "test", "Test", WS_OVERLAPPED or WS_SYSMENU, _
                       0, 0, 0, 0, NULL, NULL, NULL, NULL )

ShowWindow( hwnd, SW_SHOWNORMAL )

do while GetMessage( @msg, NULL, 0, 0 ) > 0
    UpdateWindow( hwnd )  ' <-- changed position (new)
    if IsDialogMessage(hwnd, @msg ) = 0 then
        TranslateMessage( @msg )
        DispatchMessage( @msg )
    end if
loop
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Windows GUI

Postby MichaelW » Nov 14, 2016 7:14

Assuming I understand what you are trying to do, after you finish drawing the image use InvalidateRect to add the client area to the window's update region so the client area will be redrawn on the next WM_PAINT message.

You can use GetClientRect to copy the coordinates of the client area to a RECT structure that you then pass to the InvalidateRect function.

Your app will need a message loop, something like that shown above (but note that there will be no need to call UpdateWindow in the message loop), so it can receive and dispatch messages, and a window procedure that processes the necessary messages, which may be:

WM_CREATE

WM_PAINT

WM_TIMER

WM_CLOSE

WM_DESTROY

And possibly others depending on when you are drawing/redrawing the image, for example, drawing the image only once in the WM_CREATE handler, or at intervals in the WM_TIMER handler, or in response to some user action, etc.
Provoni
Posts: 319
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Windows GUI

Postby Provoni » Nov 15, 2016 9:15

Thanks allot MrSwiss and MichaelW. The issue is resolved now.
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: Windows GUI

Postby Kamui_Kazuma » Dec 17, 2016 5:24

MrSwiss wrote:Easy, write an additional file with: ProgName.rc
that contains something like:

Code: Select all

FB_PROGRAM_ICON ICON "C:/Path/to/file/IconName.ico"
Thats all ...



Sorry to bug you, but I can't seem to get this to work...
I've been using this in the RC file:

Code: Select all

FB_PROGRAM_ICON ICON "STS.ico"

and this on the command line:

Code: Select all

fbc "Program.bas" "Program.rc" -v

herein lies the problem:
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: Program.bas -o Program.asm (main module)
assembling: C:\Users\<INSERT NAME HERE>\Desktop\Software\FreeBASIC\bin\win32\as.exe --30 --strip-local-absolute "Program.asm" -o "Program.o"
compiling rc: C:\Users\<NAME>\Desktop\Software\FreeBASIC\bin\win32\GoRC.exe /ni /nw /o /fo "Program.obj" "Program.rc"

Error!
No resources found in RC file
OBJ file not made
compiling rc failed: 'C:\Users\<NAME>\Desktop\Software\FreeBASIC\bin\win32\GoRC.exe' terminated with exit code 1



I'm also using win8.1 ( 64-bit )... if that makes any difference.
EDIT:
It would seem Windows 8 is being an issue (you don't say?).
Provoni
Posts: 319
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Windows GUI

Postby Provoni » Jan 08, 2017 9:38

Do you still need help Kazuma?

I want to thank everyone that helped me in this thread and in the other threads over the years. And special thanks to Lothar for the GUI and the FreeBASIC developers for a crazy fast BASIC.

Here's the program that came of this thread: https://drive.google.com/file/d/0B5r0rD ... dJQjA/view

No source or documentation. It is a powerful and quick homophonic substitution solver. It makes quick work of ciphers such as the Zodiac 408 and the second Beale cipher but no solution can be found for the Zodiac 340.

Feel free to join in for the quest to solve the Zodiac 340 in the cipher section at http://www.zodiackiller.net/ I am there as Jarlve.
Lothar Schirm
Posts: 333
Joined: Sep 28, 2013 15:08
Location: Bavaria, Germany

Re: Windows GUI

Postby Lothar Schirm » Jan 08, 2017 15:18

Provoni, thank you for the presentation of your work! I am very pleased to see what you can do with my simple library.
I would be happy if somebody could help Kazuma, I never worked with icons and recource files.
MrSwiss
Posts: 3263
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Windows GUI

Postby MrSwiss » Jan 08, 2017 15:42

Kamui_Kazuma wrote:Sorry to bug you, but I can't seem to get this to work...
I've been using this in the RC file:

Code: Select all

FB_PROGRAM_ICON ICON "STS.ico"
Well, it's not the same as:

Code: Select all

FB_PROGRAM_ICON ICON "*full path to*/STS.ico"
If the ICON file is NOT found, GoRC gives an ERROR.
replace *full path to* with the real path (to the icon file) in your code ...
St_W
Posts: 1476
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Windows GUI

Postby St_W » Jan 08, 2017 19:15

Relative paths to the icon file are no problem; absolute paths are not required, I'd even say you should avoid using them as it voids portability. Additionally the error message would be a different one if the icon file couldn't be found.

However, I can't reproduce your problem / error message. Is there any other content in the .rc file? Have you tried a minimal example like this (put the files in the same folder):

test.bas

Code: Select all

screen 12: sleep

test.rc

Code: Select all

FB_PROGRAM_ICON ICON "test.ico"

test.ico: http://www.iconarchive.com/download/i20 ... -zilla.ico

put everything in a single folder and compile using:

Code: Select all

fbc test.bas test.rc
fxm
Posts: 9179
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Windows GUI

Postby fxm » Jan 08, 2017 20:16

Kamui_Kazuma wrote:Sorry to bug you, but I can't seem to get this to work...
I've been using this in the RC file:

Code: Select all

FB_PROGRAM_ICON ICON "STS.ico"

and this on the command line:

Code: Select all

fbc "Program.bas" "Program.rc" -v

herein lies the problem:
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
standalone
target: win32, 486, 32bit
compiling: Program.bas -o Program.asm (main module)
assembling: C:\Users\<INSERT NAME HERE>\Desktop\Software\FreeBASIC\bin\win32\as.exe --30 --strip-local-absolute "Program.asm" -o "Program.o"
compiling rc: C:\Users\<NAME>\Desktop\Software\FreeBASIC\bin\win32\GoRC.exe /ni /nw /o /fo "Program.obj" "Program.rc"

Error!
No resources found in RC file
OBJ file not made
compiling rc failed: 'C:\Users\<NAME>\Desktop\Software\FreeBASIC\bin\win32\GoRC.exe' terminated with exit code 1

Can you rewrite entirely the RC file to be sure than none non-printable character is eventually inserted inside it.
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: Windows GUI

Postby Kamui_Kazuma » Jan 12, 2017 21:42

Thanks fro the tips but nothing is seeming to work... exept I did try doing this on windows XP (as opposed to 8.1) and this worked, so in conclusion...
Blame Windows 8.
MrSwiss
Posts: 3263
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Windows GUI

Postby MrSwiss » Jan 12, 2017 21:51

Well, I've not had Win 8 for longer than some Months.
The Method works for certain, on Windows: Vista / 7 / 8.1 / 10.

If not, then plse. publish the .rc file, in its entirety ...
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: Windows GUI

Postby Kamui_Kazuma » Jan 13, 2017 6:32

MrSwiss wrote:Well, I've not had Win 8 for longer than some Months.
The Method works for certain, on Windows: Vista / 7 / 8.1 / 10.

If not, then plse. publish the .rc file, in its entirety ...


uhh, that's all that was in it... maybe it has to do with the icon file itself? i've been using MSPaint for creating icons as bitmaps with a pixel depth of 4.
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: Windows GUI

Postby Kamui_Kazuma » Jan 13, 2017 6:38



This link apparently has some relation to some sort of malware, please look into this.
Also where is this icon from?

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 28 guests