In-Memory Dialogs

Windows specific questions.
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Postby D.J.Peters » Mar 09, 2011 3:16

Hello Jack,

the download link should work now

http://jafile.com/uploads/freebasic/dialogs.zip

Joshy
BurghHouse
Posts: 34
Joined: Jul 09, 2008 21:57
Contact:

Re: In-Memory Dialogs

Postby BurghHouse » Jan 29, 2013 10:56

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.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: In-Memory Dialogs

Postby MichaelW » Mar 03, 2013 16:14

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:

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 )

''=============================================================================

And there are other methods.
BurghHouse
Posts: 34
Joined: Jul 09, 2008 21:57
Contact:

Re: In-Memory Dialogs

Postby BurghHouse » Mar 04, 2013 9:54

Many thanks. So simple .... !
nimdays
Posts: 219
Joined: May 29, 2014 22:01
Location: ID

Re: In-Memory Dialogs

Postby nimdays » Aug 16, 2014 20:45

Nice and simple :)
Ed Davis
Posts: 10
Joined: Jul 28, 2008 23:24

Re: In-Memory Dialogs

Postby Ed Davis » Jul 09, 2015 11:44

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)'
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: In-Memory Dialogs

Postby MichaelW » Jul 09, 2015 18:05

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.
Ed Davis
Posts: 10
Joined: Jul 28, 2008 23:24

Re: In-Memory Dialogs

Postby Ed Davis » Jul 09, 2015 18:42

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.


Thanks for the quick response.

(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...
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: In-Memory Dialogs

Postby MichaelW » Jul 09, 2015 23:15

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?

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.

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).
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: In-Memory Dialogs

Postby Kot » Dec 27, 2016 18:26

When I try to use dialogs.bas with EZTerm viewtopic.php?t=12673&highlight=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
Pierre Bellisle
Posts: 41
Joined: Dec 11, 2016 17:22

Re: In-Memory Dialogs

Postby Pierre Bellisle » Dec 27, 2016 21:45

Hi Kot,

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)
                                 
Kot
Posts: 336
Joined: Dec 28, 2006 10:34

Re: In-Memory Dialogs

Postby Kot » Dec 29, 2016 0:19

Thanks, it worked :)

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests