Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on April 17, 2018, 05:04:46 AM

Title: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 05:04:46 AM
Hello
I have created a main program "DialogWind.exe" to call a splash screen dll "mysplash.dll"

this is a test of concept that a main dialog window can call a splash screen and then revert
control back to the main dialog.  but unfortunately when the splash screen fade out, it also closes
the main dialog program. 

How to stop this from happening  so that the main dialog window does not close after splash
screen faded away?  appreciate any help

here is the main dialog code DialogWind.o2bas

Code: [Select]
' uses Dialog as main
' DialogWind.o2bas
$ filename "DialogWind.exe"
uses RTL64



sys wndproc         'Placeholder, winutil.inc
#case capital

typedef sys SYS     'FileDialog.inc
typedef char CHAR   'FileDialog.inc
% FileDialogs       'opens FileDialog in winutil.inc

uses winutil
uses glWinUtil      'OpenGL
uses imgwin

Declare Function Splash  Lib "mySplash.dll"() as Long

'% review           'opens console
uses dialogs
'namespace

#autodim off

% DS_CENTER=0x0800
% SM_CXBORDER=5
% SM_CYBORDER=6
% SWP_NOZORDER=4
% HWND_TOPMOST= -1
% HORZRES=8
% VERTRES=10



'Ids for menu
#define IDM_Load       1110
#define IDM_Exit       1111
#define IDM_Play       1112
#define IDM_Reset      1113
#define IDM_Filter     1114
#define IDM_Light      1115
#define IDM_Blend      1116
#define IDM_FullScreen 1117
#define IDM_Help       1118
#define IDM_Right      1119
#define IDM_Left       1120
#define IDM_Up         1121
#define IDM_Down       1122
#define IDM_PgUp       1123
#define IDM_PgDown     1124
#define IDM_Splash       1133

'Ids for text controls in Help
% IDC_LText1=1131
% IDC_LText2=1132

#lookahead 'for subs and functions

==============================================

'MAIN CODE
=============================================

string fn=""



sys hMenu
sys hAccel

int GdiplusToken
GLuint texture[3]  'Storage for three Texture
GLuint wi[1],ht[1]

'Prepare Textures
'----------------
glGenTextures 3, texture

GLfloat    xrot   'X Rotation
GLfloat    yrot   'Y Rotation
GLfloat xspeed    'X Rotation Speed
GLfloat yspeed    'Y Rotation Speed

GLfloat z=-5.0f   'Depth Into The Screen

GLfloat LightAmbient[]=  { 0.5f, 0.5f, 0.5f, 1.0f }
GLfloat LightDiffuse[]=  { 1.0f, 1.0f, 1.0f, 1.0f }
GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f }

GLuint filter=1    'Which Filter To Use

sys hDlgHDC


'============================================
function DlgProc( sys hDlg, uint uMsg, sys wParam, lParam ) as sys callback
 
  static bool p_toggle   'Play ON/OFF
  static bool reset=true 'Original state of image
 

  select case uMsg

    case WM_INITDIALOG
      hMenu = initMenu(hDlg)
      if SetMenu( hDlg, hMenu ) = 0 then
        mbox "SetMenu hMenu failed!"
      end if

      sys hGLrc
      hDlgHDC = GetDC( hDlg )
     
      'glWinUtil.inc
      SelectPixelFormat(hDlgHDC, 1)

      hGLrc = wglCreateContext( hDlgHDC )
      if hGLrc = 0 then
        MessageBox( hDlg, "wglCreateContext failed", 0, 0 )
        DestroyWindow( hDlg )
      end if

      if wglMakeCurrent( hDlgHDC, hGLrc ) = 0 then
        MessageBox( hDlg, "wglMakeCurrent failed", 0, 0 )
        DestroyWindow( hDlg )
      end if

 

    case WM_PAINT
   '   DrawGlScene()
      SwapBuffers( hDlgHDC )

    case WM_TIMER
   '   xrot += xspeed   'Inc x rotation
  '    yrot += yspeed   'Inc y rotation
  '    DrawGlScene()
      SwapBuffers( hDlgHDC)
           
    case WM_SIZE
      'LoWord=Width, HiWord=Height   
    '  ReSizeGLScene(loword(lParam),hiword(lParam))

    case WM_ERASEBKGND
      return 0
     

    case WM_COMMAND

      select case loword(wParam)
 
          case IDM_Splash
                  '  print "splash"
                    Splash()

          case IDCANCEL, IDM_Exit
                DestroyWindow( hDlg )

      end select


    case WM_CLOSE
      DestroyWindow( hDlg )

    case WM_DESTROY
      glDeleteTextures 3, texture
      Gdiplus 0
     
      if hGLrc then                             'Rendering Context?
        if not wglMakeCurrent(null,null) then   'Release the DC And RC Contexts   
          MessageBox(null,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
        end if
        if not wglDeleteContext(hGLrc) then     'Delete the RC
          MessageBox(null,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
        end if
        hGLrc=null                              'Set RC to null
      end if

      if hDlgHDC then
        if not ReleaseDC(hDlg,hDlgHDC) then     'Release The DC
          MessageBox(null,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION)
          hDlgHDC=null                          'Set DC to null
        end if
      end if               
      PostQuitMessage 0

  end select

  return 0
end function




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

sub WinMain()

   sys hDlg, bRet
   MSG Msg

   sys lpdt
   dyn::init(lpdt)

   Dialog( 0, 0, 0, 320, 240, "Dialog ", lpdt,
           WS_OVERLAPPEDWINDOW or DS_CENTER or WS_VISIBLE )

   hDlg = CreateModelessDialog( null, @DlgProc, 0, lpdt )


   while (bRet := GetMessage(&Msg, null, 0, 0)) != 0
     if bRet = -1 then
       'show an error message
       print "Error in Message Loop"
       end
     else
       if TranslateAccelerator( hDlg, hAccel, @Msg ) = 0 then     
         if not IsDialogMessage(hDlg, &Msg) then
 
           TranslateMessage(&Msg)
           DispatchMessage(&Msg)
 
         end if
       end if
     end if
   wend

end sub

WinMain()



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

function initMenu(sys hDlg) as sys

   MENU(hMenu)

   BEGIN
     POPUP "&File"
     BEGIN
       MENUITEM "&Load Image..." tab "Ctrl+O", IDM_Load
       MENUITEM "SEPARATOR"
       MENUITEM "E&xit" tab "Alt+F4", IDM_Exit
     ENDMenu
     POPUP "&View"
     BEGIN
       MENUITEM "&Toggle Start / Stop" tab "Ctrl+P", IDM_Play
       MENUITEM "&Reset" tab "Ctrl+R", IDM_Reset
       MENUITEM "SEPARATOR"
       MENUITEM "&Splash" tab "Ctrl+S", IDM_Splash
     ENDMenu
 

   ENDMenu



   'Accelerators
   indexbase 0
   '14 shortcuts 0-13
   ACCEL accl[13] = {
   {FVIRTKEY | FCONTROL, asc("O"), IDM_Load      },
   {FVIRTKEY | FCONTROL, asc("P"), IDM_Play      },
   {FVIRTKEY | FCONTROL, asc("R"), IDM_Reset     },
  {FVIRTKEY | FCONTROL, asc("S"), IDM_Splash     },
   {FVIRTKEY,            asc("F"), IDM_Filter    },
   {FVIRTKEY,            asc("L"), IDM_Light     },
   {FVIRTKEY,            asc("B"), IDM_Blend     },
   {FVIRTKEY,            VK_RIGHT, IDM_Right     },
   {FVIRTKEY,            VK_LEFT,  IDM_Left      },
   {FVIRTKEY,            VK_UP,    IDM_Up        },
   {FVIRTKEY,            VK_DOWN,  IDM_Down      },     
   {FVIRTKEY,            VK_PRIOR, IDM_PgUp      },
   {FVIRTKEY,            VK_NEXT,  IDM_PgDown    },     
   {FVIRTKEY,            VK_F11,   IDM_FullScreen},
   {FVIRTKEY,            VK_F1,    IDM_Help      }
   }
 
   hAccel = CreateAcceleratorTable( @accl, 14 )

   return hMenu
end function










Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 05:05:52 AM
here is the splash screen dll   mysplash.dll

Code: [Select]
'   includepath "$\inc\"
'  Apr 17 2018
'http://www.oxygenbasic.org/forum/index.php?topic=1639.0

' mysplash.o2bas
  % dll
  % FileName  "mySplash.dll"
  uses RTL64

'  Set the width and height of the display window
  % width     300
  % height    300
 
  $ fontA     "Arial",FW_SEMIBOLD

  $ title     "Splash"
   % ExplicitMain
 
 '  Note that you need to place OpenglSceneFrame.inc , winUtil.inc
'   and glWinUtil.inc into the same folder when compiling
   include   "OpenglSceneFrame.inc"

   

'  Note that we must specify exactly these equates
'  all in uppercase ,  otherwise it can results in compilation errors
#define GL_TRIANGLES        0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP     0x0008
#define  SWP_NOSIZE         0x0001
#define  SWP_NOMOVE      0x0002
#define   SWP_SHOWWINDOW      0x0040
#define  SW_SHOW   5
#define  SM_CYCAPTION  4




'========================
' this center the display window
' on the screen
' but it was not use in this program
sub Center(sys hwnd)
    RECT rc
    sys x,y
    GetWindowRect(hwnd,&rc)
    x = (GetSystemMetrics(SM_CXSCREEN) - (rc.right-rc.left))\2
    y = (GetSystemMetrics(SM_CYSCREEN) -
           (rc.bottom-rc.top+GetSystemMetrics(SM_CYCAPTION)))\2
 
    SetWindowPos (hWnd, 0, x, y, 0, 0, SWP_NOSIZE)
end sub

 




  sub initialize(sys hWnd)
  '=======================
       
  end sub
  '




  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1

'DISPLAY AND FADE OUT
  if not picking then
    static Counter '60Hz Frame counter
    counter++
    if counter>180 'AFTER 3 SECONDS
      int WindowOpacity
      int t=(counter-180)*255/120 '2 sec fade
      if t>255 then t=255
      WindowOpacity=255-t
      if counter=300 '5 SECONDS
        CloseWindow 'REQUEST SHUT DOWN
      end if
      'Set WS_EX_LAYERED on this window
      SetWindowLong(hwnd, GWL_EXSTYLE,
      GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
      SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
    end if
  end if

'  increase this angle for faster rotation between 1 and 10
   angi1=7
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

 '  Greenish Beige background color
   glClearColor .91,.94,.82,1


'  ' display the text label1
    glPushMatrix
    gltranslatef  -.63,.8,-2.5
    glScalef( 0.25, 0.25, .01)
    glColor3f  0.20, 0.0, 1.0
    gPrint    "Your Product"


 ' display the text label2
   gltranslatef  -5., -1.7,-1.0
'   glScalef( 0.15, 0.2, .01)
  glColor3f 1.0, 0.0, 0.0
   gPrint    "Label 2"




  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1




  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend


'   semi triangle  -- this work
'  glBegin  GL_TRIANGLE_FAN
   '     glcolor4f   00,  s3,  s3, 1  : glvertex3f  -s1, -s1,  s2   '1st triangle
   '      glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  -.3,-.1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  s1,  s1 ,  -s2   '2nd
    '      glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  -s1,  s2   '3rd
   '       glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  s1,  -s2      '4th
  '   glEnd

 '  Triangle  -- this work
'   ensure that  z = -1.  thru' out
 '  glBegin GL_TRIANGLES 
'       glColor3f 1.0, 0.0, 0.0 :   glVertex3f   0.0,  .3,-1.
'       glColor3f 0.0, 1.0, 0.0 :   glVertex3f  0.2, -0.1,-1.
'       glColor3f 0.0, 0.0, 1.0 :   glVertex3f  -0.2,-0.1,-1.
' glEnd


'  Triangle  -- this work
'   this place triangle off center and if we increase the  -ve z
'   the object gets smaller and will spin at a distance of 0.8 from the center
 '   glTranslatef .80, 0.0, -2.0
  ' glBegin GL_TRIANGLES
'  glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0,  .30,-1.0
'  glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
 ' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
'  glEnd

'  this work
' Half red square rotated off center
'   glTranslatef 2.40,0.0,-10.0
'   glBegin(GL_QUADS)
'  glColor3f   1.0, 0.0, 1.0
'  glVertex3f -1.0,-1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f  1.0,-1.0, 0.0
'  glVertex3f  1.0, 1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f -1.0, 1.0, 0.0
'  glEnd


'  rotating  off center Cube  -- this work
 ' glTranslatef -2.0, -2.0, -12.0
 ' glBegin GL_QUADS
 ' glColor3f   0.0, 1.0, 0.0
 ' glVertex3f  1.0, 1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
'  glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f  1.0, 1.0, 1.0
 ' glColor3f   1.0, 0.5, 0.0
 ' glVertex3f  1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glColor3f   1.0, 0.0, 0.0
'  glVertex3f  1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f  1.0,-1.0, 1.0
  'glColor3f   1.0, 1.0, 0.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f  1.0, 1.0,-1.0
  'glColor3f   0.0, 0.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0, 1.0
' glColor3f  1.0, 0.0, 1.0
 ' glVertex3f 1.0, 1.0,-1.0
 ' glVertex3f 1.0, 1.0, 1.0
 ' glVertex3f 1.0,-1.0, 1.0
'  glVertex3f 1.0,-1.0,-1.0
' glEnd
 

' DrawDiamond   -- this work  very well
    glTranslatef 1.4,0.0,-20.0
      glbegin GL_TRIANGLE_FAN  'top part
          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
         glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
       glend
       glbegin GL_TRIANGLE_FAN    'bottom part
         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
      glend



    'draws a 3D cube object  -- drawcube  works
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
  '     glTranslatef 1.4,0.0,-7.0
  '    glBegin  GL_QUADS
  '      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  '     glcolor3ub 255,0,0
   '    glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
 '      glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
  '     glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
  '     glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

   '    glcolor3ub 255,255,0
   '    glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
   '    glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
   '    glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

    '   glcolor3ub 255,0,255
    '   glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
   '    glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
   '    glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
    '   glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

   '    glcolor3ub 0,255,255
  '     glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
   '    glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
    '   glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
     '  glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
  '  glEnd
   
  sleep (2)
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
   glLoadIdentity
      glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
      glBegin  GL_QUADS
         glColor3f   0.0,  1.0,  0.0         ' Set the color to green
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Top)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Top)
         glVertex3f -1.0,  1.0,  1.0         ' Bottom left of the quad (Top)
         glVertex3f  1.0,  1.0,  1.0         ' Bottom right of the quad (Top)

         glColor3f   1.0,  0.5,  0.0         ' Set the color to orange
         glVertex3f  1.0, -1.0,  1.0         ' Top right of the quad (Bottom)
         glVertex3f -1.0, -1.0,  1.0         ' Top left of the quad (Bottom)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Bottom)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Bottom)

         glColor3f   1.0,  0.0,  0.0         ' Set the color to red
         glVertex3f  1.0,  1.0,  1.0         ' Top right of the quad (Front)
         glVertex3f -1.0,  1.0,  1.0         ' Top left of the quad (Front)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom left of the quad (Front)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom right of the quad (Front)

         glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
         glVertex3f  1.0, -1.0, -1.0         ' Top right of the quad (Back)
         glVertex3f -1.0, -1.0, -1.0         ' Top left of the quad (Back)
         glVertex3f -1.0,  1.0, -1.0         ' Bottom left of the quad (Back)
         glVertex3f  1.0,  1.0, -1.0         ' Bottom right of the quad (Back)

         glColor3f   0.0,  0.0,  1.0         ' Set the color to blue
         glVertex3f -1.0,  1.0,  1.0         ' Top right of the quad (Left)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Left)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Left)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom right of the quad (Left)

         glColor3f   1.0,  0.0,  1.0         ' Set the color to violet
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Right)
         glVertex3f  1.0,  1.0,  1.0         ' Top left of the quad (Right)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom left of the quad (Right)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Right)
      glEnd


   sleep (2)
 '   draw the pyramid using triangles
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the diamond smaller
 ' // Reset the view
      glLoadIdentity

      glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis

      glBegin %GL_TRIANGLES
         ' Front
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Front)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Left of triangle (Front)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Right of triangle (Front)

         ' Right
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Right)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Left of triangle (Right)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Right of triangle (Right)

         ' Back
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Back)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Left of triangle (Back)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Right of triangle (Back)

         ' Left
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Left)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Left of triangle (Left)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Right of triangle (Left)
      glEnd





  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub


Function Splash() as Long , export
' display the window and centralize it  using place = 2
MainWindow     width,height,%WS_POPUP ,2
End Function



Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 05:11:19 AM
here are all the exe and dll and inc files

Run   DialogWind.exe -->  View --> Splash

Splash screen appears and then fade away  but later on it  also closes the DialogWind program ??
Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 07:01:40 AM
i have replaced the closewindows statement with  PostQuitMessage 0
inside mySplash.o2bas 

then the main dialog is not close after splash screen faded away

but when i click on splash again there is an error message  -- registration fail

 it looks like the splash is still lurking in the memory and not close at all

Code: [Select]
'   includepath "$\inc\"
'  Apr 17 2018
'http://www.oxygenbasic.org/forum/index.php?topic=1639.0

' mysplash.o2bas
  % dll
  % FileName  "mySplash.dll"
  uses RTL64

'  Set the width and height of the display window
  % width     300
  % height    300
 
  $ fontA     "Arial",FW_SEMIBOLD

  $ title     "Splash"
   % ExplicitMain
 
 '  Note that you need to place OpenglSceneFrame.inc , winUtil.inc
'   and glWinUtil.inc into the same folder when compiling
   include   "OpenglSceneFrame.inc"

   

'  Note that we must specify exactly these equates
'  all in uppercase ,  otherwise it can results in compilation errors
#define GL_TRIANGLES        0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP     0x0008
#define  SWP_NOSIZE         0x0001
#define  SWP_NOMOVE      0x0002
#define   SWP_SHOWWINDOW      0x0040
#define  SW_SHOW   5
#define  SM_CYCAPTION  4




'========================
' this center the display window
' on the screen
' but it was not use in this program
sub Center(sys hwnd)
    RECT rc
    sys x,y
    GetWindowRect(hwnd,&rc)
    x = (GetSystemMetrics(SM_CXSCREEN) - (rc.right-rc.left))\2
    y = (GetSystemMetrics(SM_CYSCREEN) -
           (rc.bottom-rc.top+GetSystemMetrics(SM_CYCAPTION)))\2
 
    SetWindowPos (hWnd, 0, x, y, 0, 0, SWP_NOSIZE)
end sub

 




  sub initialize(sys hWnd)
  '=======================
       
  end sub
  '




  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1

'DISPLAY AND FADE OUT
  if not picking then
    static Counter '60Hz Frame counter
    counter++
    if counter>180 'AFTER 3 SECONDS
      int WindowOpacity
      int t=(counter-180)*255/120 '2 sec fade
      if t>255 then t=255
      WindowOpacity=255-t
      if counter=300 '5 SECONDS
    '   CloseWindow 'REQUEST SHUT DOWN
        PostQuitMessage 0
      end if
      'Set WS_EX_LAYERED on this window
      SetWindowLong(hwnd, GWL_EXSTYLE,
      GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
      SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
    end if
  end if

'  increase this angle for faster rotation between 1 and 10
   angi1=7
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

 '  Greenish Beige background color
   glClearColor .91,.94,.82,1


'  ' display the text label1
    glPushMatrix
    gltranslatef  -.63,.8,-2.5
    glScalef( 0.25, 0.25, .01)
    glColor3f  0.20, 0.0, 1.0
    gPrint    "Your Product"


 ' display the text label2
   gltranslatef  -5., -1.7,-1.0
'   glScalef( 0.15, 0.2, .01)
  glColor3f 1.0, 0.0, 0.0
   gPrint    "Label 2"




  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1




  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend


'   semi triangle  -- this work
'  glBegin  GL_TRIANGLE_FAN
   '     glcolor4f   00,  s3,  s3, 1  : glvertex3f  -s1, -s1,  s2   '1st triangle
   '      glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  -.3,-.1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  s1,  s1 ,  -s2   '2nd
    '      glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  -s1,  s2   '3rd
   '       glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  s1,  -s2      '4th
  '   glEnd

 '  Triangle  -- this work
'   ensure that  z = -1.  thru' out
 '  glBegin GL_TRIANGLES 
'       glColor3f 1.0, 0.0, 0.0 :   glVertex3f   0.0,  .3,-1.
'       glColor3f 0.0, 1.0, 0.0 :   glVertex3f  0.2, -0.1,-1.
'       glColor3f 0.0, 0.0, 1.0 :   glVertex3f  -0.2,-0.1,-1.
' glEnd


'  Triangle  -- this work
'   this place triangle off center and if we increase the  -ve z
'   the object gets smaller and will spin at a distance of 0.8 from the center
 '   glTranslatef .80, 0.0, -2.0
  ' glBegin GL_TRIANGLES
'  glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0,  .30,-1.0
'  glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
 ' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
'  glEnd

'  this work
' Half red square rotated off center
'   glTranslatef 2.40,0.0,-10.0
'   glBegin(GL_QUADS)
'  glColor3f   1.0, 0.0, 1.0
'  glVertex3f -1.0,-1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f  1.0,-1.0, 0.0
'  glVertex3f  1.0, 1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f -1.0, 1.0, 0.0
'  glEnd


'  rotating  off center Cube  -- this work
 ' glTranslatef -2.0, -2.0, -12.0
 ' glBegin GL_QUADS
 ' glColor3f   0.0, 1.0, 0.0
 ' glVertex3f  1.0, 1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
'  glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f  1.0, 1.0, 1.0
 ' glColor3f   1.0, 0.5, 0.0
 ' glVertex3f  1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glColor3f   1.0, 0.0, 0.0
'  glVertex3f  1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f  1.0,-1.0, 1.0
  'glColor3f   1.0, 1.0, 0.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f  1.0, 1.0,-1.0
  'glColor3f   0.0, 0.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0, 1.0
' glColor3f  1.0, 0.0, 1.0
 ' glVertex3f 1.0, 1.0,-1.0
 ' glVertex3f 1.0, 1.0, 1.0
 ' glVertex3f 1.0,-1.0, 1.0
'  glVertex3f 1.0,-1.0,-1.0
' glEnd
 

' DrawDiamond   -- this work  very well
    glTranslatef 1.4,0.0,-20.0
      glbegin GL_TRIANGLE_FAN  'top part
          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
         glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
       glend
       glbegin GL_TRIANGLE_FAN    'bottom part
         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
      glend



    'draws a 3D cube object  -- drawcube  works
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
  '     glTranslatef 1.4,0.0,-7.0
  '    glBegin  GL_QUADS
  '      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  '     glcolor3ub 255,0,0
   '    glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
 '      glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
  '     glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
  '     glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

   '    glcolor3ub 255,255,0
   '    glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
   '    glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
   '    glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

    '   glcolor3ub 255,0,255
    '   glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
   '    glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
   '    glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
    '   glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

   '    glcolor3ub 0,255,255
  '     glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
   '    glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
    '   glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
     '  glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
  '  glEnd
   
  sleep (2)
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
   glLoadIdentity
      glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
      glBegin  GL_QUADS
         glColor3f   0.0,  1.0,  0.0         ' Set the color to green
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Top)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Top)
         glVertex3f -1.0,  1.0,  1.0         ' Bottom left of the quad (Top)
         glVertex3f  1.0,  1.0,  1.0         ' Bottom right of the quad (Top)

         glColor3f   1.0,  0.5,  0.0         ' Set the color to orange
         glVertex3f  1.0, -1.0,  1.0         ' Top right of the quad (Bottom)
         glVertex3f -1.0, -1.0,  1.0         ' Top left of the quad (Bottom)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Bottom)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Bottom)

         glColor3f   1.0,  0.0,  0.0         ' Set the color to red
         glVertex3f  1.0,  1.0,  1.0         ' Top right of the quad (Front)
         glVertex3f -1.0,  1.0,  1.0         ' Top left of the quad (Front)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom left of the quad (Front)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom right of the quad (Front)

         glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
         glVertex3f  1.0, -1.0, -1.0         ' Top right of the quad (Back)
         glVertex3f -1.0, -1.0, -1.0         ' Top left of the quad (Back)
         glVertex3f -1.0,  1.0, -1.0         ' Bottom left of the quad (Back)
         glVertex3f  1.0,  1.0, -1.0         ' Bottom right of the quad (Back)

         glColor3f   0.0,  0.0,  1.0         ' Set the color to blue
         glVertex3f -1.0,  1.0,  1.0         ' Top right of the quad (Left)
         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Left)
         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Left)
         glVertex3f -1.0, -1.0,  1.0         ' Bottom right of the quad (Left)

         glColor3f   1.0,  0.0,  1.0         ' Set the color to violet
         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Right)
         glVertex3f  1.0,  1.0,  1.0         ' Top left of the quad (Right)
         glVertex3f  1.0, -1.0,  1.0         ' Bottom left of the quad (Right)
         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Right)
      glEnd


   sleep (2)
 '   draw the pyramid using triangles
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the diamond smaller
 ' // Reset the view
      glLoadIdentity

      glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis

      glBegin %GL_TRIANGLES
         ' Front
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Front)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Left of triangle (Front)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Right of triangle (Front)

         ' Right
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Right)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f  1.0, -1.0,  1.0         ' Left of triangle (Right)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Right of triangle (Right)

         ' Back
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Back)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f  1.0, -1.0, -1.0         ' Left of triangle (Back)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Right of triangle (Back)

         ' Left
         glColor3f   1.0,  0.0,  0.0         ' Red
         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Left)
         glColor3f   0.0,  0.0,  1.0         ' Blue
         glVertex3f -1.0, -1.0, -1.0         ' Left of triangle (Left)
         glColor3f   0.0,  1.0,  0.0         ' Green
         glVertex3f -1.0, -1.0,  1.0         ' Right of triangle (Left)
      glEnd





  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub


Function Splash() as Long , export
  ' display the window and centralize it  using place = 2
     MainWindow     width,height,%WS_POPUP ,2
End Function


Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 07:31:17 AM

i also tried  replacing closewindow with

 PostMessage(hwnd, %WM_CLOSE,0,0)

but it didn't work ?

Title: Re: Main dialog.exe calling a splash dll
Post by: Mike Lobanovsky on April 17, 2018, 07:45:20 AM
PostQuitMessage 0 isn't logically correct here, Chris. This API is meant to shut down the entire process rather than just close a window. You could try PostMessage(hWnd, WM_CLOSE, 0, 0) but it won't work either. (I see you have already tried it yourself)I think this particular app is too complicated to isolate the bug. We should probably roll back to the original WM_TIMER + message box setup and try to examine exactly why it works in 32 bits but fails in 64 bits.
Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 17, 2018, 07:58:40 AM
Thanxx Mike

maybe something to do with the commonly  use handle  hwnd 

if we are allow to have a different variable name for hwnd while inside mysplash.dll  it might
solve the issue? 

maybe something like  hwsplash
Title: Re: Main dialog.exe calling a splash dll
Post by: Mike Lobanovsky on April 17, 2018, 08:16:12 AM
Of course you may try and see if it's gonna work for you. (I think it isn't tho)

But either way, it won't give us an answer why posted messages don't work in the original one-window setup of WM_TIMER + message box...
Title: Re: Main dialog.exe calling a splash dll
Post by: Arnold on April 18, 2018, 02:32:24 AM
Hi Charles,

I do not know if this will be helpful, but I have started to learn about custom controls:
https://www.codeproject.com/Articles/559385/Custom-Controls-in-Win32-API-The-Basics (https://www.codeproject.com/Articles/559385/Custom-Controls-in-Win32-API-The-Basics)

As I am only at the beginning I wanted to wait a little bit, but maybe it is already of interest. I try to do the examples using MainWindow of winutil.inc. This is the very first trivial example:

Code: [Select]
'https://www.codeproject.com/Articles/559385/Custom-Controls-in-Win32-API-The-Basics

' application doing actually nothing but creating a main window and
' the custom control as its only child


$ filename "trivial.exe"

'uses rtl32
'uses rtl64

uses WinUtil

#autodim off

% GCL_HBRBACKGROUND = -10
% COLOR_BTNFACE=15
% DT_CENTER=1
% DT_VCENTER=4
% DT_SINGLELINE=32
% SWP_NOZORDER=4
% SIZE_RESTORED=0
% SIZE_MAXIMIZED=2

function RGB(int r, g, b) as int
    return (r + g*256 + b*65536)
end Function



'Window class
string CUSTOM_WC= "CustomControl"

'Register/Unregister the window class
declare sub CustomRegister()
declare sub CustomUnregister()


sys hInstance=inst
sys hwndCustom

% CUSTOM_ID = 100
% MARGIN    =   7


MainWindow 350,250,WS_OVERLAPPEDWINDOW


function WndProc(sys hwnd, Msg, wParam, lParam) as sys callback

    select Msg
       
        case WM_CREATE
            SetWindowText(hwnd, "App Name")
            'Replaces the window-class style bits: color background   
            SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE + 1)           

            CustomRegister()
            hwndCustom = CreateWindowEx(0, CUSTOM_WC, null, WS_CHILD | WS_VISIBLE,
                                        0,0,0,0, hwnd, CUSTOM_ID, hInstance, null)

        case WM_CLOSE
            DestroyWindow(hwnd)

        case WM_SIZE
            if wParam = SIZE_MAXIMIZED or wParam = SIZE_RESTORED then
                word cx = LOWORD(lParam)
                word cy = HIWORD(lParam)
                SetWindowPos(hwndCustom, null, MARGIN, MARGIN,
                             cx-2*MARGIN, cy-2*MARGIN, SWP_NOZORDER)
            end if
           
        case WM_DESTROY
            CustomUnregister()
            PostQuitMessage(0)
                   
        case else
            return DefWindowProc(hwnd, Msg, wParam, lParam)

    end select
   
    return 0
end function

=======================================


sub CustomPaint(sys hwnd)
    PAINTSTRUCT ps
    sys hdc
    RECT rect

    GetClientRect(hwnd, &rect)

    hdc = BeginPaint(hwnd, &ps)
    SetTextColor(hdc, RGB(0,0,0))
    SetBkMode(hdc, TRANSPARENT)
    DrawText(hdc, "Hello World!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER)
    EndPaint(hwnd, &ps)
end sub


function CustomProc(sys hwnd, uint uMsg, sys wParam, lParam) as sys callback
    select uMsg
        case WM_PAINT
            CustomPaint(hwnd)
            return 0
    end select
    return DefWindowProc(hwnd, uMsg, wParam, lParam)
end function


sub CustomRegister()
    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
end sub

sub CustomUnregister()
    UnregisterClass(CUSTOM_WC, null)
end sub
Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 18, 2018, 05:21:27 AM
hello Roland

i can't compile your program got an error message at the code

Code: [Select]
SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE + 1)

Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 18, 2018, 05:38:25 AM
i added these code and it can compile but cannot run the exe?

Code: [Select]
uses rtl64
uses WinUtil
! SetClassLongPtr lib "user32.dll" (sys hWnd, int nIndex , sys dwNewLong) as sys


Title: Re: Main dialog.exe calling a splash dll
Post by: Arnold on April 18, 2018, 05:57:16 AM
Hi Chris,

my code will run, but your windata.inc, minwin.inc and user.inc are not up-to-date. Try SetClassLong instead. This was suggested by Charles:

http://www.oxygenbasic.org/forum/index.php?topic=1544.msg17694#msg17694 (http://www.oxygenbasic.org/forum/index.php?topic=1544.msg17694#msg17694)

Roland
Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc on April 18, 2018, 07:01:00 AM
Thanxx Roland

got it compile with the latest O2 compiler and use SetClassLong

only problem is that i cannot set the background color to other color?
Title: Re: Main dialog.exe calling a splash dll
Post by: Arnold on April 18, 2018, 07:33:45 AM
Try e.g.:
...
SetClassLongPtr(hwnd, GCL_HBRBACKGROUND, COLOR_BTNFACE+4)
...
    SetTextColor(hdc, RGB(255,255,255))
...

but these aspects are only peripheral at the moment.

Edit: I was wondering if I can use a normal child window in order to do some actions, or if I must see a splash screen as a customized control. But I do not know enough about OpenGl so I cannot judge what would be the correct way.
Title: Re: Main dialog.exe calling a splash dll
Post by: Charles Pegge on April 18, 2018, 02:34:24 PM
I think I've cracked it. The basic solution is to avoid using PostQuitMessage in OpenGlSceneFrame. Instead using DestroyWindow, then UnregisterClass before returning from the splash call.

I will get some sleep now and do some more testing..
Title: Re: Main dialog.exe calling a splash dll
Post by: Arnold 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
Title: Re: Main dialog.exe calling a splash dll
Post by: Mike Lobanovsky 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.
Title: Re: Main dialog.exe calling a splash dll
Post by: Charles Pegge 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
Title: Re: Main dialog.exe calling a splash dll
Post by: Charles Pegge 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.

Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc 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
Title: Re: Main dialog.exe calling a splash dll
Post by: Charles Pegge on April 19, 2018, 12:34:29 PM
Hi Chris,

You'll need these updates:
Title: Re: Main dialog.exe calling a splash dll
Post by: chrisc 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
Title: Re: Main dialog.exe calling a splash dll
Post by: Charles Pegge 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.