In-Memory Dialogs
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
-
- Posts: 34
- Joined: Jul 09, 2008 21:57
- Contact:
Re: In-Memory Dialogs
I use this library a lot - thanks - but there is one issue I can't solve.
When the dialog box is displayed the title line contains a blank icon. (the full title line is <blank icon> <Title text> <window control buttons _ - and x>)
I'd like the blank icon to be my program's icon (as displayed on its window) but I can't figure out how to achieve that.
I've waded through the library documentation and the Windows documentation (until my eyes burned) but I can’t find it.
It's either really easy or terribly complicated - if its' the former, please enlighten me.
When the dialog box is displayed the title line contains a blank icon. (the full title line is <blank icon> <Title text> <window control buttons _ - and x>)
I'd like the blank icon to be my program's icon (as displayed on its window) but I can't figure out how to achieve that.
I've waded through the library documentation and the Windows documentation (until my eyes burned) but I can’t find it.
It's either really easy or terribly complicated - if its' the former, please enlighten me.
Re: In-Memory Dialogs
Sorry about the slow response, I’ve been very busy with work recently. You can get a handle for the icon, by any of several methods, and then send it to the dialog window in a WM_SETICON message, specifying ICON_SMALL in wParam, something like this:
And there are other methods.
Code: Select all
''=============================================================================
#include "dialogs.bas"
''=============================================================================
function DialogProc( byval hwndDlg as HWND, _
byval uMsg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM ) as integer
dim as HICON hIcon
select case uMsg
case WM_INITDIALOG
hIcon = LoadImage( 0, "freebasic.ico", IMAGE_ICON,0,0, LR_LOADFROMFILE )
SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, cast(LPARAM,hIcon) )
case WM_COMMAND
select case wParam
case IDCANCEL
EndDialog( hwndDlg, null )
end select
case WM_CLOSE
EndDialog( hwndDlg, null )
end select
return 0
end function
''=============================================================================
dim as LPDLGTEMPLATE lpdt
dim as HWND hDlg
Dialog( 0, 0, 0, 80, 60, "Test", lpdt, WS_OVERLAPPEDWINDOW or DS_CENTER )
CreateModalDialog( 0, @DialogProc, 0, lpdt )
''=============================================================================
-
- Posts: 34
- Joined: Jul 09, 2008 21:57
- Contact:
Re: In-Memory Dialogs
Many thanks. So simple .... !
Re: In-Memory Dialogs
Nice and simple :)
Re: In-Memory Dialogs
Has anyone gotten dialogs.bas to work with later versions of FreeBASIC?
With fbc 1.02.1 I get:
FreeBASIC Compiler - Version 1.02.1 (04-25-2015), built for win64 (64bit)
Copyright (C) 2004-2015 The FreeBASIC development team.
standalone
c:\bin\bas\fb\Dialogs>..\fbc ex1.bas
c:\bin\bas\fb\Dialogs\dialogs.bas(343) error 20: Type mismatch, before ')' in 'u
l = cast(ULONG,g_lpw) + 3'
c:\bin\bas\fb\Dialogs\dialogs.bas(346) error 28: Expected pointer, before ')' in
'g_lpw = cast(LPWORD,ul)'
With fbc 1.02.1 I get:
FreeBASIC Compiler - Version 1.02.1 (04-25-2015), built for win64 (64bit)
Copyright (C) 2004-2015 The FreeBASIC development team.
standalone
c:\bin\bas\fb\Dialogs>..\fbc ex1.bas
c:\bin\bas\fb\Dialogs\dialogs.bas(343) error 20: Type mismatch, before ')' in 'u
l = cast(ULONG,g_lpw) + 3'
c:\bin\bas\fb\Dialogs\dialogs.bas(346) error 28: Expected pointer, before ')' in
'g_lpw = cast(LPWORD,ul)'
Re: In-Memory Dialogs
The problem is not with the version, but with the change to 64-bit code. Correcting the problem required only a small modification, new version in first post, but note that I had only a limited time to test. I should have anticipated this problem and corrected it years ago.
Re: In-Memory Dialogs
Thanks for the quick response.MichaelW wrote:The problem is not with the version, but with the change to 64-bit code. Correcting the problem required only a small modification, new version in first post, but note that I had only a limited time to test. I should have anticipated this problem and corrected it years ago.
(later)
Hmmm. I downloaded from the link in the first message. I noticed that the date of dialogs.bas inside the .zip is still 2009. I unzipped, and when I compiled, I get the same error.
Is it possible the .zip did not get updated?
I tried downloading again just to make sure, but it appears I'm getting the old .zip file. If you put a new one up, I guess it could be some sort of cache issue on my end...
Re: In-Memory Dialogs
I have nothing to do with the zip archive and no control over it. What I updated was the code in the first code block in the first post of this thread.Ed Davis wrote: Hmmm. I downloaded from the link in the first message. I noticed that the date of dialogs.bas inside the .zip is still 2009. I unzipped, and when I compiled, I get the same error.
Is it possible the .zip did not get updated?
And I forgot to add that I tested the 64-bit functionality with compiler version 1.02.0 (03-23-2015), built for win64 (64bit).
Re: In-Memory Dialogs
When I try to use dialogs.bas with EZTerm http://www.freebasic.net/forum/viewtopi ... ght=ezterm I get the error:
dialogs.bas(129) error 57: Type mismatch, at parameter 3 of MULTIBYTETOWIDECHAR() in 'asciistring, _'
How can I fix it?
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
win7 64bit
dialogs.bas(129) error 57: Type mismatch, at parameter 3 of MULTIBYTETOWIDECHAR() in 'asciistring, _'
How can I fix it?
FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
win7 64bit
-
- Posts: 56
- Joined: Dec 11, 2016 17:22
Re: In-Memory Dialogs
Hi Kot,
Try something like this...
Pierre
Try something like this...
Pierre
Code: Select all
gpWord += MultiByteToWideChar(CP_ACP, _
MB_PRECOMPOSED, _
Cast(LPCSTR, StrPtr(asciiString)), _
-1, _
Cast(LPWSTR, gpWord), _
Len(asciiString) + 2)
Re: In-Memory Dialogs
Thanks, it worked :)
Re: In-Memory Dialogs
>fbc64 --version
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
>fbc64 Button_grid_demo.bas
dialogs.bas(131) error 58: Type mismatch, at parameter 3 of MULTIBYTETOWIDECHAR() in 'asciistring, _'
To get it to compile I had to copy asciiString to a Zstring:
No doubt there is a more elegant solution.
FreeBASIC Compiler - Version 1.09.0 (2021-12-31), built for win64 (64bit)
Copyright (C) 2004-2021 The FreeBASIC development team.
standalone
>fbc64 Button_grid_demo.bas
dialogs.bas(131) error 58: Type mismatch, at parameter 3 of MULTIBYTETOWIDECHAR() in 'asciistring, _'
To get it to compile I had to copy asciiString to a Zstring:
Code: Select all
sub GenUstring( byref asciiString as string )
'' If asciiString is null, skip the first element of
'' the array, leaving it set to zero (no string).
''
if asciiString = "" then
g_lpw += 1
else
dim as ZString * 256 ZasciiString
ZasciiString = asciiString
'' CP_ACP specifies that the function should use
'' the current system ANSI code page to perform
'' the conversion to Unicode.
''
g_lpw += MultiByteToWideChar( CP_ACP, _
MB_PRECOMPOSED, _
@Zasciistring, _
-1, _
cast(LPWSTR,g_lpw), _
len(asciiString) + 2 )
end if
end sub
Re: In-Memory Dialogs
This is just what I need --- but sadly the link to the zip file is broken
Many thanks for a great post.
Dave
Many thanks for a great post.
Dave
Re: In-Memory Dialogs
OK I have modified the grid of buttons example to give me what I basicaly want.
I would like to put some text BESIDE each button - I have looked for an example of writing to the main area of the dialog but have been unable to find anything. I happily admit to being a newbie at this so any advice is very welcome.
Thanks in advance,
Dave
I would like to put some text BESIDE each button - I have looked for an example of writing to the main area of the dialog but have been unable to find anything. I happily admit to being a newbie at this so any advice is very welcome.
Thanks in advance,
Dave