Author Topic: Main dialog.exe calling a splash dll  (Read 3401 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #15 on: April 19, 2018, 01:28:09 AM »
Hi Charles,

I had to interrupt yesterday, but this morning I tried to create a splash screen before starting an app. This is nothing sophisticated, no timer etc. And I do not know how this could be done with OpenGl. But maybe it can be of some help nevertheless. I also think using DestroyWindow and UnregisterClass will be the best solution.

Roland

Edit: small modification, as I forgot UnregisterClass after DestroyWindow myself

Code: [Select]
$ filename "splash_window.exe"

'uses rtl32
'uses rtl64

uses WinUtil

% DT_CENTER=1
% DT_VCENTER=4
% DT_SINGLELINE=32
% GCLP_HBRBACKGROUND= -10

hInstance=inst

'Window class
string CUSTOM_WC= "CustomControl"
sys hSplash

MainWindow 600,400,WS_OVERLAPPEDWINDOW

declare sub showSplash()

function WndProc(sys hwnd, uMsg, wParam, lParam) as sys callback
       
    select uMsg
       
        case WM_CREATE
          showSplash()
          Sleep (2000)
          DestroyWindow(hSplash)
          UnregisterClass(CUSTOM_WC,hInstance)
                               
        case WM_CLOSE
            DestroyWindow(hwnd)
       
        case WM_DESTROY
            PostQuitMessage(0)
       
        case else
            return DefWindowProc(hwnd, uMsg, wParam, lParam)
           
    end select
   
    return 0
end function

sub showSplash()
    WNDCLASS wc

    wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW
    wc.lpfnWndProc = @CustomProc
    wc.hCursor = LoadCursor(null, IDC_ARROW)
    wc.lpszClassName = strptr CUSTOM_WC
    if not RegisterClass(&wc) then
      mbox "Cannot register Custom Control"
    end if

    hSplash = CreateWindowEx(WS_EX_TOPMOST, CUSTOM_WC, "", WS_CHILD or WS_POPUP,
                            200, 200, 300, 200,
                            0, null, hInstance, null)

end sub

function CustomProc(sys hwnd, uint uMsg, sys wParam, lParam) as sys callback
    sys hdc
    PAINTSTRUCT ps
    RECT rc

    select uMsg
        case WM_CREATE
            'Display the Splash Window.
            ShowWindow hwnd, SW_SHOW
            sys hbr=CreateSolidBrush(14000)
            DeleteObject(SetClassLongPtr(hwnd,GCLP_HBRBACKGROUND, hbr))
            InvalidateRect (hwnd,null,TRUE)
           
            GetClientRect(hwnd, &rc)
            hdc = BeginPaint(hwnd, &ps)
            SetTextColor(hdc,  32000)
            DrawText(hdc, "Hello World!", -1, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER)
            EndPaint(hwnd, &ps)

            return 0
    end select
    return DefWindowProc(hwnd, uMsg, wParam, lParam)
end function
« Last Edit: April 19, 2018, 02:16:02 AM by Arnold »

Mike Lobanovsky

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #16 on: April 19, 2018, 02:06:33 AM »
There is a problem with WM_TIMER and other posted messages that will have to be resolved sooner or later regardless.

Charles Pegge

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #17 on: April 19, 2018, 09:32:29 AM »
Thanks for the demo, Roland,

I think creating a main-window inside a main-window is likely to cause problems, so I would generate the splash screen and shut it down before generating the main app.

For Chris's code. I put it right at the start, where it cannot interfere with anything else:
Code: [Select]
' uses Dialog as main
' DialogWind.o2bas
$ filename "DialogWind.exe"
uses RTL64

! Splash  Lib "mySplash.dll"
splash
...

Nearly ready.  There will be a fader macro in OpenglSceneFrame for fade-ins and fade-outs. There will also be a FrameCount to syncronize events, and CloseScene to self-terminate a program.

Self-Destructing within wndproc:
Code: [Select]
  case WM_DESTROY
  '
  if not running then exit function 'PREVENT RECURSION
  ...
  running=0 'STATUS FLAG
  DestroyWindow hWnd 'SELF DESTRUCT but will also send another wm_destroy message
« Last Edit: April 19, 2018, 09:56:01 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #18 on: April 19, 2018, 10:25:24 AM »
Chris's modified code
+
FadeinFadeout.o2bas example
+
The .inc files, which should be transferred to the inc folder.


chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #19 on: April 19, 2018, 12:03:37 PM »
Thanxx Charles

when i compile the mysplash.o2bas  i  got this error message

looks like i need to place in a declaration for getwindowlongptr() function  inside  OpenglsceneFrame.inc ?

please advise

Charles Pegge

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #20 on: April 19, 2018, 12:34:29 PM »
Hi Chris,

You'll need these updates:

chrisc

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #21 on: April 20, 2018, 04:48:01 AM »
Thanxx a lot Charles,

the initial splash screen works but when i run it with the button View --> splash

it does not close the previous splashes and if you click on button View --> splash
multiple times, then you will see multiple splash screens appearing as
all previous splash screens are not close.

maybe i'll stick to one initial splash screen when program starts
and remove the button for  View --> splash

Charles Pegge

  • Guest
Re: Main dialog.exe calling a splash dll
« Reply #22 on: April 20, 2018, 06:10:03 AM »
Yes, you can't run a main-window inside another main-window with any certainty, especially when it is an animation. You have to run the main-windows separately.