User Tools

Site Tools


using_20an_20atl_20container_20control

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
using_20an_20atl_20container_20control [2018/03/31 13:19] – external edit 127.0.0.1using_20an_20atl_20container_20control [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 4: Line 4:
 ==== Initialisation ==== ==== Initialisation ====
 \\  The first step is some necessary initialisation:\\ \\  \\  The first step is some necessary initialisation:\\ \\ 
 +<code bb4w>
         INSTALL @lib$+"WINLIB5"         INSTALL @lib$+"WINLIB5"
  
Line 9: Line 10:
         SYS "GetProcAddress", atl%, "AtlAxWinInit" TO `AtlAxWinInit`         SYS "GetProcAddress", atl%, "AtlAxWinInit" TO `AtlAxWinInit`
         SYS `AtlAxWinInit`         SYS `AtlAxWinInit`
 +</code>
 \\  \\ 
 ==== Creating a menu ==== ==== Creating a menu ====
 \\  In this example application a simple menu is created, giving the option to open or close the file to be viewed, or to exit the program. You may want to select the file in a different way.\\ \\  \\  In this example application a simple menu is created, giving the option to open or close the file to be viewed, or to exit the program. You may want to select the file in a different way.\\ \\ 
 +<code bb4w>
         SYS "CreatePopupMenu" TO hfile%         SYS "CreatePopupMenu" TO hfile%
         SYS "AppendMenu", hfile%, 0, 101, "&Open"+CHR$9+"Ctrl+O"         SYS "AppendMenu", hfile%, 0, 101, "&Open"+CHR$9+"Ctrl+O"
Line 21: Line 24:
         SYS "SetMenu", @hwnd%, hmenu%         SYS "SetMenu", @hwnd%, hmenu%
         SYS "DrawMenuBar", @hwnd%         SYS "DrawMenuBar", @hwnd%
 +</code>
 \\  \\ 
 ==== Event handling ==== ==== Event handling ====
 \\  The code below handles menu selection and window-resizing events. The latter is to ensure that if your main window is resized by the user, the viewer window is resized to suit:\\ \\  \\  The code below handles menu selection and window-resizing events. The latter is to ensure that if your main window is resized by the user, the viewer window is resized to suit:\\ \\ 
 +<code bb4w>
         ON SYS Click% = @wparam% : RETURN         ON SYS Click% = @wparam% : RETURN
         ON MOVE PROCmove(@msg%, @wparam%, @lparam%) : RETURN         ON MOVE PROCmove(@msg%, @wparam%, @lparam%) : RETURN
Line 40: Line 45:
         UNTIL FALSE         UNTIL FALSE
         END         END
 +</code>
 Note that the "END" statement is only included for neatness; it can never be reached. The global variable **hATL%** is the window handle of the viewer window.\\ \\  Note that the "END" statement is only included for neatness; it can never be reached. The global variable **hATL%** is the window handle of the viewer window.\\ \\ 
 ==== Opening the file ==== ==== Opening the file ====
 \\  The code below displays a file selector dialogue, and opens the selected file (if any):\\ \\  \\  The code below displays a file selector dialogue, and opens the selected file (if any):\\ \\ 
 +<code bb4w>
         DEF FNopen(hw%)         DEF FNopen(hw%)
         LOCAL fs{}, rc{}, fp%, ff$, res%         LOCAL fs{}, rc{}, fp%, ff$, res%
Line 73: Line 80:
  
         = FN_createwindow("AtlAxWin", $$fp%, 0, 0, rc.r%-rc.l%, rc.b%-rc.t%, 0, &200000, 0)         = FN_createwindow("AtlAxWin", $$fp%, 0, 0, rc.r%-rc.l%, rc.b%-rc.t%, 0, &200000, 0)
 +</code>
 If the file is successfully opened the function returns the handle of the viewer window. If you want the viewer window to occupy less that the full area of your output window you can determine the dimensions in a way other than **SYS "GetClientRect"**.\\ \\  If the file is successfully opened the function returns the handle of the viewer window. If you want the viewer window to occupy less that the full area of your output window you can determine the dimensions in a way other than **SYS "GetClientRect"**.\\ \\ 
 ==== Window resizing ==== ==== Window resizing ====
 \\  The code below simply resizes the viewer window to match the client area of your output window. Again you may wish to determine the dimensions differently:\\ \\  \\  The code below simply resizes the viewer window to match the client area of your output window. Again you may wish to determine the dimensions differently:\\ \\ 
 +<code bb4w>
         DEF PROCmove(M%, W%, L%)         DEF PROCmove(M%, W%, L%)
         IF M% = 5 IF hATL% SYS "SetWindowPos", hATL%, 0, 0, 0, L% AND &FFFF, L% >>> 16, 6         IF M% = 5 IF hATL% SYS "SetWindowPos", hATL%, 0, 0, 0, L% AND &FFFF, L% >>> 16, 6
         ENDPROC         ENDPROC
 +</code>
 \\  For more information on the Active Template Library consult Microsoft's [[http://msdn2.microsoft.com/en-us/library/t9adwcde(VS.80).aspx|ATL Reference]]. \\  For more information on the Active Template Library consult Microsoft's [[http://msdn2.microsoft.com/en-us/library/t9adwcde(VS.80).aspx|ATL Reference]].
using_20an_20atl_20container_20control.1522502388.txt.gz · Last modified: 2024/01/05 00:16 (external edit)