Dialogs from a DLL

Windows specific forum
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Dialogs from a DLL

Post by jonljacobi »

I have a ton of these and for the life of me I can't seem to find a way to access them. I can load bitmaps and icons. There's a CreateDialogParam_ macro for PB so why wouldn't this work? This is driving me crazy.

I've tested with several dlls, but the following code uses cmdial32.dll

Declare Callback(WindowID, Message, wParam, lParam)

hwndMain = OpenWindow(#PB_Any, 100, 100, 480, 480, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "MainWindow")
Debug(hwndMain)
hlib = OpenLibrary(#PB_Any, "cmdial32.dll")
hndModule = GetModuleHandle_("cmdial32.dll")
hndDialog = CreateDialogParam_(hndModule, "#101", hwndMain, @Callback(), 1)
hndResource = LoadResource_(hndModule, "#101")
hndIcon = LoadIcon_(hndModule, "#112")
hndBitmap = LoadBitmap_(hndModule, "#113")

Debug(hlib)
Debug(hndModule)
Debug(@Callback())
Debug(hndResource)
Debug(hndDialog)
Debug(hndIcon)
Debug(hndBitmap)
success = CloseLibrary(hlib)
Debug(success)
Delay(1000)

Procedure Callback(WindowID, Message, wParam, lParam)
Debug(lParam)
ProcedureReturn DefWindowProc_(WindowID, Message, wParam, lParam)
EndProcedure


Any ideas?

Thanks in advance.

Jon :?:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

[edit] wrong answer of mine erased.
Last edited by netmaestro on Tue Feb 21, 2006 7:13 pm, edited 2 times in total.
BERESHEIT
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post by jonljacobi »

Actually "#101" is the name of the template that I found with the dll2PBlib program as well as the Pelles IDE. And I've tried addressing a string. If you run the code, it does return handles for the icon and bitmap which are similarly named.

I've tried renaming templates in my own dll and calling them by different names. This code is only the tip of the iceberg as far as what I've tried. I'd love for someone to point out a stupid reason for me not be able to get it to work. Everything seems valid to me.

The alternative is rewriting or porting to C where I know the code works and spending another week or more changing syntax yet again.

Cheers, Jon
:(
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

This is uncharted territiory for me so don't put too much weight on what I say here and feel free to pick the code apart. ;)

When using Dialog #101, XP returns an error 1411
1411 Class does not exist.
Two things stick out when viewing the resource.
CLASS "IConnMgr Class"
and
CONTROL "", 1001, "IConnMgr Bitmap Class", 0x5080020E, 4, 4, 220, 86
Now if I use Dialog #133, it seems to work fine.

Code: Select all

Procedure DialogProc(WindowID, Message, wparam, lparam) 
  Select Message 
    Case #WM_INITDIALOG 
      result = #True 
    Case #WM_COMMAND 
      If wparam = #IDOK Or wparam = #IDCANCEL 
        result = #True 
        EndDialog_(WindowID, wparam) 
      EndIf 
    Default 
      result = #False 
  EndSelect 
  ProcedureReturn result 
EndProcedure 

hwndMain = OpenWindow(#PB_Any, 100, 100, 480, 480, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "MainWindow") 
If hwndMain 
  hlib = OpenLibrary(#PB_Any, "cmdial32.dll") 
  If hlib 
    hndModule = GetModuleHandle_("cmdial32.dll") 
    If hndModule 
      hndDialog = DialogBoxParam_(hndModule, 133, WindowID(hwndMain), @DialogProc(), 1) 
      If hndDialog 
        hndIcon = LoadIcon_(hndModule, 112) 
        hndBitmap = LoadBitmap_(hndModule, 113) 
        ShowWindow_(hndDialog, #SW_SHOW) 
      EndIf 
    EndIf 
    CloseLibrary(hlib) 
  EndIf 
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_Event_CloseWindow 
EndIf 
End 
And that in a nutshell is as far as I can go. :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post by jonljacobi »

It works! Eureka! I don't understand why, but I'll dig into it. At least I know now that it can be done. Thanks loads..

:D

Cheers, Jon
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post by jonljacobi »

Okay, without having and registering that class, you'll never get those low number cmdial32 dialogs, but it was the WindowID() function that was the key. Now it works perfectly and I can access my dialog DLL. Apparently, there's something I didn't know and still don't understand about the way PB is using handles. The API implementation of PB is less well documented than it's OS-agnostic portion. However, I'm now certain I won't have to switch languages to get this done and that's a load off my mind.

Sincere thanks for taking the time to look into it. Very clean and readable code by the way. My real stuff is a lot better than what I pasted here. :oops:

Cheers, Jon
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

yeah, yeah they all say that... :lol:
Last edited by netmaestro on Tue Feb 21, 2006 7:14 pm, edited 2 times in total.
BERESHEIT
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Happy to hear you'll be sticking with PureBasic jonljacobi :)
Apparently, there's something I didn't know and still don't understand about the way PB is using handles.
Take a look at blueznl's site. It should help clear this up for you. :)
http://www.xs4all.nl/~bluez/datatalk/pu ... ber_handle
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post by jonljacobi »

netmaestro wrote:yeah, yeah they all say that... :D
No, really... I swear! :lol:

I'll post the API/MDI code when I get it all finished. If you look at the rather primative program I'm trying to update and port (www.jonljacobi.com/other stuff/Take Note) you'll see why I need finer control over the windows. There's both a floating and compacted arrangement.

Cheers, Jon
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post by jonljacobi »

I posted the final stuff under a new topic. Finally found the little "code" button that lets you insert code without all the indents removed.

Cheers, Jon
Post Reply