home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / clip_sib / clipsib.frm (.txt) next >
Visual Basic Form  |  1995-02-27  |  21KB  |  445 lines

  1. Form1
  2. 0Run This Program As An EXE File For Best Results
  3. Form1%
  4. ShoppingList
  5. FindPic
  6. Command2
  7. Cancel
  8. Command1
  9. Check2
  10. Whole Word
  11. Check1
  12. Case Sensitive
  13. FindTextBox
  14.     FindTitle
  15. Label3
  16. Find What:
  17. PyramidPic
  18. MeatList
  19. PyramidPic
  20. VegList
  21.     FruitList
  22. PastryList
  23.     WindowPic
  24. ChessHelpCmdBut
  25. ChessPic
  26. PyramidPic
  27. Label4
  28. %Drag FIND Box Around By Its Title Bar
  29. Label1
  30. Shopping List
  31. Label2
  32. "Use Lists To Build A Shopping List
  33. ControlhWnd
  34. BringWindowToTop
  35. hWndG
  36. SetWindowPos
  37. hWndInsertAfter
  38. wFlags
  39. GetNextWindow
  40. wFlagX
  41. IsWindowVisiblex
  42. GetActiveWindow
  43.     GetParent
  44.     SetParentC
  45.     hWndChild2
  46. hWndNewParent
  47. GetWindowLong
  48. nIndex
  49. SetWindowLong
  50.     dwNewLong
  51. WS_CLIPSIBLINGS
  52. SWP_NOSIZE
  53. SWP_NOMOVE
  54. SWP_NOZORDER
  55. SWP_NOREDRAW
  56. SWP_NOACTIVATE
  57. SWP_DRAWFRAME
  58. SWP_SHOWWINDOWi
  59. SWP_HIDEWINDOW
  60. SWP_NOCOPYBITSd
  61. SWP_NOREPOSITIONK
  62. GW_HWNDLAST
  63. GW_HWNDNEXT
  64. GW_HWNDPREV
  65. GWL_WNDPROC
  66. GWW_HINSTANCEj
  67. GWW_HWNDPARENT
  68. GWW_ID
  69.     GWL_STYLE
  70. GWL_EXSTYLE
  71. Truez
  72. Falseq
  73. XStart
  74. YStart'
  75.     OKToMove1)
  76.     OKToMove2
  77.     OKToMove3
  78.     OKToMove4y
  79.     OKToMove6
  80. WindowStack
  81. NumOfControls
  82. hWndWindowToMoveo
  83. NeedsFixing
  84. GW_HWNDFIRST
  85. GW_OWNER
  86. GW_CHILDl
  87. SetClipSibling
  88. Parentv
  89.     GetWindow
  90. SetClipSiblingBit
  91. Style
  92. WS_CLIPSIBLING
  93. Form_Clickw
  94. @    Form_Loadf
  95. Form1
  96. Screen4
  97. Width
  98. Height~
  99. GetWindowsDirectoryV
  100. lpBuffer
  101. nSize
  102. WinDir
  103. ChessBmp
  104. OF_EXIST
  105. OpenFile/
  106. lpFileName
  107. lpReOpenBuff
  108. OFSTRUCT
  109. wStyle
  110. Buffer
  111. ChessPicH
  112. Picture
  113. MousePointer
  114. ChessPic_Click
  115. ChessPic_MouseDownV
  116. Button
  117. Shift
  118. OkToMoveChessPic
  119. ChessPic_MouseMove
  120. ChessHelpCmdBut
  121. Visible
  122. FormParenti
  123. ControlParent
  124. ParentType
  125. AnyControl
  126. NestedSibling
  127. SetClipSiblingBits^
  128. hWndParentj
  129.     WindowPic
  130. Picture2_Click
  131. Picture2_MouseDownE
  132. OkToMovePicture2
  133. Picture2_MouseMove
  134. Picture2
  135. Command1
  136. WindowPic_Click
  137. ChessHelpCmdBut_Click
  138. List1_Click?
  139. VegList
  140. MeatListz
  141.     FruitList
  142. PastryList
  143. TopListBoxU
  144. PrecedingListBox
  145. MeatList_Click
  146. MeatList_GotFocus
  147. FruitList_Click0
  148. FruitList_GotFocus
  149. PastryList_Click
  150. VegList_Click
  151. VegList_GotFocus
  152. @    FillLists
  153. PastryList_GotFocus
  154. ClickedToGetFocus
  155. ShoppingList
  156.     ListIndex
  157. BringToTop
  158. ThisList
  159. InsertAfter
  160. ClickedToSetFocus
  161. OkToMoveWindowPic
  162. GetWindowNext
  163. PyramidBmp:    
  164. PyramidPic
  165. Pyramid
  166. PyramidPic_Click
  167. Index
  168. PyramidPic_MouseDown
  169. Pic4'    
  170. OkToMovePyramidPicQ    @
  171. PyramidPic_MouseMove
  172. Label3_Click\    
  173. FindLabel_Clicko    
  174. FindLabel_MouseDown
  175. OkToMoveFindPic
  176. FindLabel_MouseMove
  177. FindPic
  178. FindTitle_Click
  179. FindTitle_MouseDown
  180. FindTitle_MouseMove
  181. Timer1_Timer
  182. hwndFindPic
  183. Timer1
  184. Enabled
  185. Purpose
  186. program
  187. demonstrate
  188. Command1_Click
  189. Control
  190.  CLPSIB.BAS Rev. 1.0
  191.  Keith Funk (CIS 72240, 2020)7
  192.  Nov. 3, 1991 
  193.    Many thanks to Daniel Appleman (Desaware) for explainingg
  194.    the Win3 WS_CLIPSIBLINGS style without which this program
  195.    could not have been written. I'd also like to thank
  196.    Ted Young and Jonathan Zuk for the help they have given
  197.    me in learning the Win3 API.o
  198.    The purpose of the program is to demonstrate how to
  199.    implement overlapping controls in a VB program.
  200.    NOTE that the Form and all controls have their ScaleMode sett
  201.    to PIXELS. Also, AutoRedraw is False for all controls. Thee
  202.    Picture Controls that contain the bitmaps PYRAMID.BMP
  203.    and CHESS.BMP have AutoSize set to True. No other control
  204.    properties have any particular relevance for this demo.
  205.    The program is FREEWARE. Feel free to use any part of
  206.    it in your own programs. Feedback and comments wouldd
  207.    be appreciated. Have fun.
  208. -- Declarations for external functions.
  209.    CTLHWND.DLL is a custom DLL written by Jonathan Zuk. It
  210.    is included, with thanks to Jonathan, as part of CLPSIB.
  211. ctlhwnd.dll
  212. KernelZ
  213. Kernel
  214. -- Window style.
  215. -- THE SECRET TO SUCCESS<g>a
  216. -- SetWindowPos Flags
  217. -- GetWindow() Constants
  218. -- Window field offsets for GetWindowLong() and GetWindowWord()e
  219. -- OpenFile action..
  220. -- The mouse location when the mouse button is initially pressed.
  221. -- Flags to indicate when a picture can be moved. A move
  222.    is not allowed while a DoEvents is in progress.
  223. -- Keeps track of the location of the list boxes in them
  224.    window stack.
  225. -- Flag to determine if user clicked a listbox to make
  226.    a selection or just to bring it to the front.
  227. BringToTop
  228.    This routine brings ThisList to the top of the window
  229.    stack so it appears on top of the other listboxes..
  230.    It also sets some global variables that keep track of
  231.    the current order of the window stack..
  232. -- If ThisList is already at the top then there's nothing to do.
  233. -- Put the listbox that is currently on top back in its proper location.
  234.    Note that we don't need to specify x,y,cx and cy because the flagsf
  235.    SWP_NOMOVE and SWP_NOSIZE tell Win3 to ignore these values.
  236. -- Find out which window precedes ThisList in the window stack.t
  237. -- Move this listbox to the front of the group ofu
  238.    listboxes *BUT* behind the FindPic control. We aree
  239.    demonstrating how a control (FindPic) can *always*w
  240.    remain in front of all other controls even when
  241.    these controls are being re-arranged.
  242. -- Tell Click Event to ignore this click because
  243.    user is just bringing the list to the front.e
  244. ChessHelpCmdBut_Click
  245.    The main purpose of this control is to demonstratee
  246.    how setting the WS_CLIPSIBLINGS style bit allows youu
  247.    to slide a picture underneath another control. NOTE
  248.    that this control has been placed on the WindowPicc
  249.    control. It is *not* on Form1..
  250. Use the LEFT Mouse Button to drag the small pictures on top of CHESS.BMP and to scroll CHESS.BMP.
  251. Chess Help
  252. ChessPic_MouseDown
  253.    This control is filled with the bitmap CHESS.BMPP
  254.    during the Form1_Load Event. Because its AutoSize
  255.    Property is set to True, it becomes much larger thann
  256.    the WindowPic control on which it is placed, but youu
  257.    can only see the area of CHESS.BMP that is within
  258.    the boundaries of WindowPic. However, you can use yourr
  259.    mouse to -move- different parts of CHESS.BMP into the
  260.    visible area. NOTE how the picture -slides under- the
  261.    Help Command Button. Too neat.<g>
  262.    This is where the moving of CHESS.BMP begins. It is
  263.    continued in the MouseMove Event.
  264. -- Save mouse X/Y so MouseMove can determine how far
  265.    the mouse has moved.o
  266. -- Set flag for MouseMove.
  267. ChessPic_MouseMove
  268.    This is the routine that actually moves CHESS.BMP..
  269.    Note that the flag OkToMoveChessPic and the DoEventss
  270.    are *absolutely* essential to the correct operation
  271.    of this routine..
  272. -- Only move the picture if left button is down.
  273. -- Only move the picture if no DoEvent is in progress.
  274. -- DoEvents has finished.o
  275. Command1_Click
  276.    In a -real- program, this button would activate the
  277.    code to find text..
  278. You Actually Expected Something To Happen?<g>
  279. FillLists
  280.    Fills the meat, vegetable, fruit and pastry lists with goodies.
  281. -- Fill the Meat List.
  282. Rib Roast
  283. Pork Chops
  284. Chicken
  285. Ground Beef
  286. Lamb Chops
  287. Spare Ribs
  288. Pigs Feet
  289. Sausage
  290. Hot Dogs
  291. -- Fill the Vegetable List.
  292. Potatoes
  293. Onions
  294. Turnip
  295. Carrots
  296. Beans
  297. Eggplant
  298. Celery
  299. -- Fill the Fruit List
  300. Apples
  301. Oranges
  302. Pears
  303. Grapes
  304. Melons
  305. Lemons
  306. Limes
  307. Apricots
  308. Quinces
  309. Plums
  310. Peaches
  311. -- Fill the Pastry List 
  312. Donuts
  313. Bread
  314. Crullers
  315. Cherry Pie
  316. Lemon Cake
  317. Cookies
  318. Macaroons
  319. Muffins
  320. Brownies
  321. Date Squares
  322. Peach Pie
  323. FindTitle_MouseDown
  324.    This Picture Control acts as a dark blue title bar for the FindPicc
  325.    Picture Control. Its purpose is to allow FindPic and all its childd
  326.    windows to be dragged around the Form..
  327.    NOTE: That FindPic *always* appears on top of any other control..
  328.    Very desireable for a Find Dialog Box..
  329. -- Save mouse X/Y so MouseMove can determine how far
  330.    the mouse has moved.u
  331. -- Set flag for MouseMove.
  332. FindTitle_MouseMove
  333.    This is the routine that actually drags FindPic around.
  334. -- Only move the picture if left button is down.
  335. -- Only move the picture if no DoEvent is in progress.
  336. -- DoEvents has finished.o
  337. Form_Load
  338. -- Display hourglass mousepointer.
  339. -- Show the window centered on the screen.
  340. *   THIS IS THE KEY TO THE ENTIRE DEMO. TRY COMMENTING OUT
  341. *   THE CALL TO SetClipSiblings AND WATCH THE PROGRAM FALL TO PIECES.*
  342. D* **
  343. -- Set the CLIPSIBLING Style bit for all child windows.d
  344.  SET UP THE CHESS.BMP CONTROLS.R
  345. -- Find the Win3 directory and append a backslash.
  346. Can't Find Window's Directory
  347. Fatal Error
  348. -- Strip trailing \0.
  349. -- If CHESS.BMP exists, load it into ChessPic.
  350. CHESS.BMP
  351. Sorry, This Program Requires The Win3 Bitmap CHESS.BMP.
  352. FATAL ERROR
  353. -- Put the Command Button for CHESS.BMP on top of the
  354.    Chess Picture, so the picture can be scrolled
  355.    underneath it. 
  356. -- If PYRAMID.BMP exists, load it into the three PyramidPic controls.A
  357. PYRAMID.BMP
  358. Sorry, This Program Requires The Win3 Bitmap PYRAMID.BMP.
  359. FATAL ERROR
  360. -- Make sure the PyramidPics are higher in the window stack than
  361.    WindowPic so they will appear on top of CHESS.BMP.-
  362. -- Display the Chess demo controls.W
  363.    SET UP THE LIST BOX CONTROLS.
  364. -- Add items to the lists.
  365. -- Place the controls in their correct order. 
  366.    Meat, Veg, Fruit then Pastry.
  367. -- Display them.
  368. -- improves the way Win3 initially paints the display.
  369. -- Set Global variables to keep track of which listbox
  370.    is on top and which list it normally comes after.
  371.    SET UP THE FIND CONTROLS.
  372. -- Make the Find "dialog box" the top most child
  373.    window of the Form, so it is *always* displayed on top of
  374.    all other child windows. Then make it visible.i
  375. -- improves the way Win3 initally paints the screen.
  376. -- Set standard mousepointer.n
  377. FruitList_Click
  378.    Adds the item selected from FruitList to the ShoppingList..
  379. -- Don't do anything if user just clicked to bring
  380.    the list to the front.r
  381. -- Add selected item to our shopping list.
  382. FruitList_GotFocus
  383.    Displays this list on top of the other list boxes..
  384. MeatList_Click
  385.    Adds the item selected from MeatList to the ShoppingList.
  386. -- Don't do anything if user just clicked to bring
  387.    the list to the front.s
  388. -- Add selected item to our shopping list.
  389. MeatList_GotFocus
  390.    Displays this list on top of the other list boxes.-
  391. PastryList_Click
  392.    Adds the item selected from PastryList to the ShoppingList.
  393. -- Don't do anything if user just clicked to bring
  394.    the list to the front.s
  395. -- Add selected item to our shopping list.
  396. PastryList_GotFocus
  397.    Displays this list on top of the other list boxes.-
  398. PyramidPic_MouseDown
  399.    This is where the start of moving the small picture controls containing
  400.    PYRAMID.BMP begins.
  401. -- Save mouse X/Y so MouseMove can determine how far
  402.    the mouse has moved.u
  403. -- Set flag for MouseMove.
  404. PyramidPic_MouseMove
  405.    This is the routine that actually moves the picture controls that
  406.    contain PYRAMID.BMP..
  407. -- Only move the picture if the left mouse button is down.
  408. -- Only move the picture if no DoEvent is in progress.
  409. -- DoEvents has finished.o
  410. SetClipSiblingBit
  411.    This routine sets the WS_CLIPSIBLINGS style bit for
  412.    all child windows of the Parent window *and* anyi
  413.    child windows of the child windows. The routine iss
  414.    recursive..
  415.    *** THIS IS THE KEY ROUTINE OF THE PROGRAM. ***
  416.    Setting the WS_CLIPSIBLINGS style bit is all that is-
  417.    needed to make VB work properly with overlappingg
  418.    controls. Or at least, so it appears to me.
  419. -- Get the first child window.
  420. -- Set the CLIPSIBLING bit for each child window.n
  421.    Loop terminates when GetWindowNext runs out ofu
  422.    child windows and returns NULL.
  423. -- Get current style.y
  424. -- Set the bit.e
  425. -- Set new style.,
  426. -- Process any child windows of this window.
  427. -- recursive call.
  428. -- Get the next top level child window.y
  429. VegList_Click
  430.    Adds the item selected from VegList to the ShoppingList.-
  431. -- Don't do anything if user just clicked to bring
  432.    the list to the front.s
  433. -- Add selected item to our shopping list.
  434. VegList_GotFocus
  435.    Displays this list on top of the other list boxes.-
  436. WindowPic_Click
  437.    This control is the Parent of the ChessPic control.
  438.    That is, ChessPic has been placed *on* this control,,
  439.    *not* on Form1. It serves as a clipping window whichh
  440.    restricts the amount of ChessPic which is visible..
  441.    NOTE that ChessPic has its AutoSize Property set to
  442.    True, so when CHESS.BMP is loaded into its Picturee
  443.    Property, ChessPic becomes *much* larger than thiss
  444.    picture control..
  445.