home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / grafik / show3d / nm_mod.bas < prev    next >
Encoding:
BASIC Source File  |  1995-02-27  |  14.1 KB  |  480 lines

  1. Option Explicit
  2. DefInt A-Z
  3. Declare Function LockWindowUpdate Lib "User" (ByVal hwndLock As Integer) As Integer
  4. Declare Function SetSysModalWindow Lib "User" (ByVal hWnd As Integer) As Integer
  5. Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags) As Long
  6. Declare Function GetWinFlags Lib "Kernel" () As Long
  7. Declare Function GetVersion Lib "Kernel" () As Long
  8. Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As Integer
  9. Declare Function GetFreeSystemResources Lib "User" (ByVal fuSysResource As Integer) As Integer
  10. Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
  11. Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal nIndex As Integer) As Integer
  12. Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer
  13. Declare Function RemoveMenu Lib "User" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
  14. Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpDefault As String, ByVal lpReturnedString$, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
  15. Declare Sub WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpString$, ByVal lplFileName$)
  16.  
  17. Global Const C_AnzahlBreite = 3
  18. Global Const C_AnzahlHoehe = 7
  19.  
  20. Const WF_STANDARD = &H10
  21. Const WF_ENHANCED = &H20
  22. Const WF_80x87 = &H400
  23. Const SM_DEBUG = 22
  24. Const GFSR_SYSTEMRESOURCES = &H0
  25. Const MF_BYPOSITION = &H400
  26. Const KEY_ESCAPE = &H1B
  27.  
  28.  
  29. Global G_TabName$
  30. Global Const C_Ordner = 1
  31. Global Const C_Dokument = 2
  32. Global Const C_Information = 3
  33.  
  34. Function F_EntferneNull$ (Text As String)
  35. Text = Trim$(Text)
  36. Do
  37.     If Len(Text$) <= 1 Then Exit Do
  38.     If Left$(Text, 1) = Chr$(0) Then
  39.         Text = Mid$(Text, 2)
  40.     Else
  41.         Exit Do
  42.     End If
  43. Loop
  44. Do
  45.     If Len(Text$) <= 1 Then Exit Do
  46.     If Right$(Text, 1) = Chr$(0) Then
  47.         Text = Mid$(Text, 1, Len(Text) - 1)
  48.     Else
  49.         Exit Do
  50.     End If
  51. Loop
  52.  
  53. F_EntferneNull = Text
  54. End Function
  55.  
  56. Function F_FileExist (ByVal DateiName$)
  57. On Error Resume Next
  58. Dim Datei$
  59. If DateiName$ = "" Then Exit Function
  60. Datei$ = Dir$(DateiName$)
  61. If Trim$(Datei$) = "" Or Asc(DateiName$) = 0 Then
  62.     F_FileExist = False
  63. Else
  64.     F_FileExist = True
  65. End If
  66.  
  67. End Function
  68.  
  69. Function F_GetPrivatIni (ByVal section As String, ByVal Key As String) As String
  70. Dim lplFileName As String
  71. Dim retVal As String, AppName As String, worked As Integer
  72.  
  73. lplFileName$ = App.EXEName + ".INI"
  74.  
  75.     retVal = String$(255, 0)
  76.     worked = GetPrivateProfileString(section, Key, "", retVal, Len(retVal), lplFileName$)
  77.     If worked = 0 Then
  78.         F_GetPrivatIni = ""
  79.     Else
  80.         F_GetPrivatIni = Left(retVal, worked)
  81.     End If
  82. End Function
  83.  
  84. Function F_Test256Color ()
  85.  
  86. Dim Tmp_AnzahlBitP As Integer
  87. Dim Tmp_AnzahlFarben As Integer
  88.  
  89. ' Anzahl Farben
  90. Tmp_AnzahlFarben = GetDeviceCaps(Screen.ActiveForm.hDC, 104)
  91.  
  92. ' Anzahl Bit pro Pixel
  93. Tmp_AnzahlBitP = GetDeviceCaps(Screen.ActiveForm.hDC, 12)
  94. If Tmp_AnzahlBitP = 8 And Tmp_AnzahlFarben = 256 Then
  95.     F_Test256Color = True
  96. Else
  97.     F_Test256Color = False
  98. End If
  99.  
  100. End Function
  101.  
  102. Sub FreezeOff ()
  103. Dim Dummy As Integer
  104. Dummy = LockWindowUpdate(0)
  105. End Sub
  106.  
  107. Sub FreezeOn (ByVal Handle As Integer)
  108. Dim Dummy As Integer
  109. Dummy = LockWindowUpdate(Handle)
  110. End Sub
  111.  
  112. Function HIBYTE (ShortInt As Integer) As Integer
  113.     HIBYTE% = ShortInt% \ 256
  114. End Function
  115.  
  116. Function HIWORD (LongInt As Long) As Integer
  117.     HIWORD% = LongInt& \ 65536
  118. End Function
  119.  
  120. Function LOBYTE (ShortInt As Integer) As Integer
  121.     LOBYTE% = ShortInt% Mod 256
  122. End Function
  123.  
  124. Function LOWORD (LongInt As Long) As Integer
  125.     LOWORD% = LongInt& Mod 65536
  126. End Function
  127.  
  128. Sub P_ChangeFont (F_Source As Form, F_Name As String)
  129. Dim I As Integer
  130.  
  131. For I = 0 To F_Source.Controls.Count - 1
  132.     F_Source.Controls(I).FontName = F_Name
  133. Next I
  134.  
  135. End Sub
  136.  
  137. ' Alle Schriftgr÷ssen der Controls innerhalb des Formulars F_Source
  138. ' werden auf die neue gr÷sse Fontsize angepasst
  139. '
  140. ' F_Source -> Formular
  141. ' Fontsize -> Schriftgr÷sse
  142. '
  143. Sub P_ChangeFontSize (F_Source As Form, FontSize As Single)
  144.  
  145. On Error Resume Next
  146. Dim I As Integer
  147.  
  148. For I = 0 To F_Source.Controls.Count - 1
  149.     F_Source.Controls(I).FontSize = FontSize
  150. Next I
  151.  
  152. End Sub
  153.  
  154. Sub P_ReadDataBase ()
  155.  
  156.  
  157.  
  158.  
  159. End Sub
  160.  
  161. ' Die Feldnamen der Tabelle TableName aus der Datenbank DataBaseName
  162. ' werden in einem Control O_Source angezeigt
  163. '
  164. ' DataBaseName -> Name der Datenbank
  165. ' TableName -> Name der Tabelle oder Name des Queries
  166. ' O_Source -> Name des Objektes (Liste oder Combo-Box)
  167. '
  168. Sub P_ReadFields (ByVal DataBaseName As String, ByVal TableName As String, O_Source As Control)
  169. On Error Resume Next
  170. Dim DB As Database
  171. Dim Sn As SnapShot
  172. Dim I As Integer
  173.  
  174. Set DB = OpenDatabase(DataBaseName)
  175. Set Sn = DB.CreateSnapshot(TableName)
  176.  
  177. O_Source.Clear
  178. For I = 0 To Sn.Fields.Count - 1
  179.     O_Source.AddItem Sn.Fields(I).Name
  180. Next I
  181.  
  182. End Sub
  183.  
  184. ' Alle Records des Feldes FieldName aus der Tabelle TableName
  185. ' werden in einem Control O_Source angezeigt
  186. '
  187. ' DataBaseName -> Name der Datenbank
  188. ' TableName -> Name der Tabelle oder Name des Queries
  189. ' FieldName -> Feldname
  190. ' O_Source -> Name des Objektes (Liste oder Combo-Box)
  191. '
  192. Sub P_ReadFieldValue (DataBaseName As String, ByVal TableName As String, ByVal FieldName As String, O_Source As Control)
  193.  
  194. Dim DB As Database
  195. Dim Sn As SnapShot
  196.  
  197. Dim I As Integer
  198.  
  199. Set DB = OpenDatabase(DataBaseName)
  200. Set Sn = DB.CreateSnapshot(TableName)
  201.  
  202. O_Source.Clear
  203. Do While Not Sn.EOF
  204.     O_Source.AddItem Format$(Sn.Fields(FieldName))
  205.     Sn.MoveNext
  206. Loop
  207.     
  208. End Sub
  209.  
  210. ' Alle Tabellen der Datenbank DataBaseName werden im
  211. ' Control O_Source angezeigt
  212. '
  213. ' DataBaseName -> Name der Datenbank'
  214. ' O_Source -> Name des Objektes (Liste oder Combo-Box)
  215. '
  216. Sub P_ReadTables (DB As Database, O_Source As Control)
  217.  
  218. Dim TableList As SnapShot
  219.  
  220. Set TableList = DB.ListTables()
  221.  
  222. O_Source.Clear
  223. While TableList.EOF = False
  224.     If TableList!Attributes And &H80000002 Then
  225.     Else
  226.         O_Source.AddItem TableList!Name
  227.     End If
  228.     TableList.MoveNext
  229. Wend
  230.  
  231. End Sub
  232.  
  233. Sub P_RemoveItemsSysMenu (F_Source As Form, Positon As Integer)
  234.     
  235.     Dim HSysMenu As Integer
  236.     Dim Dummy As Integer
  237.     HSysMenu = GetSystemMenu(F_Source.hWnd, 0)
  238.     Dummy = RemoveMenu(HSysMenu, Positon, MF_BYPOSITION)
  239.  
  240. End Sub
  241.  
  242. Sub P_ResizeFormCenter (Source As Form)
  243.  
  244. Source.Left = (Screen.Width - Source.Width) / 2
  245. Source.Top = (Screen.Height - Source.Height) / 2
  246.  
  247. End Sub
  248.  
  249. ' Anpassen eines Control-Arrays O_Source2 an ein ⁿberliegendes Control O_Source1
  250. ' wobei die Ausrichtung vertikal erfolgt.
  251. '
  252. ' F_Source -> Formular
  253. ' O_Source1 -> ⁿberliegendes Control
  254. ' O_Source2 -> Control-Array das ausgerichtet werden muss
  255. ' Anzahl -> Anzahl der Objekte(O_Source2) die angezeigt werden mⁿssen
  256. ' Abstand1 ->  Linker, rechter, oberer und unterer Abstand des auszurichtenden objektes an
  257. ' das Vaterelement
  258. ' Abstand2 -> Zwischenabstand
  259. '
  260. Sub P_ResizeMultiObjectToParents (F_Source As Form, O_Source1 As Control, O_Source2 As Control, Anzahl As Integer, Abstand1 As Integer, Abstand2 As Integer)
  261. Dim I As Integer
  262. Dim II As Integer
  263. Dim Tmp_Hoehe As Integer
  264. Dim Tmp_Breite As Integer
  265. Dim Tmp_Zwischenhoehe As Integer
  266.  
  267.  
  268. For I = 0 To F_Source.Controls.Count - 1
  269.     If O_Source2 = F_Source.Controls(I) Then
  270.         For II = I To F_Source.Controls.Count - 1
  271.             If O_Source2 = F_Source.Controls(II) Then
  272.                 F_Source.Controls(II).Visible = False
  273.             End If
  274.         Next II
  275.         Tmp_Hoehe = O_Source1.Height - (Abstand1 * 2) - ((Anzahl - 1) * Abstand2)
  276.         Tmp_Breite = O_Source1.Width - (Abstand1 * 2)
  277.         Tmp_Zwischenhoehe = Tmp_Hoehe / Anzahl
  278.         For II = Anzahl - 1 To 0 Step -1
  279.             F_Source.Controls(I + II).Top = Abstand1 + (II * Tmp_Zwischenhoehe) + (II * Abstand2)
  280.             F_Source.Controls(I + II).Left = Abstand1
  281.             F_Source.Controls(I + II).Width = Tmp_Breite
  282.             F_Source.Controls(I + II).Height = Tmp_Zwischenhoehe
  283.             F_Source.Controls(I + II).Visible = True
  284.         Next II
  285.         Exit For
  286.     End If
  287. Next I
  288.  
  289. End Sub
  290.  
  291. ' Control wird an einem Formular ausgerichtet
  292. '
  293. ' F_Source -> Formular
  294. ' O_Source -> Objekt das ausgerichtet werden muss
  295. '
  296. Sub P_ResizeObjectToForm (F_Source As Form, O_Source As Control, Abstand)
  297.  
  298. O_Source.Left = Abstand
  299. O_Source.Top = Abstand
  300. O_Source.Width = F_Source.ScaleWidth - (2 * Abstand)
  301. O_Source.Height = F_Source.ScaleHeight - (2 * Abstand)
  302.  
  303. End Sub
  304.  
  305. ' Ein Control wird an einem ⁿberliegenden Control ausgerichtet
  306. '
  307. ' O_OutSource -> ⁿberliegendes Control
  308. ' O_InSource -> Control das ausgerichtet werden muss
  309. ' Abstand -> Abstand des auszurichtenden Controls zum Vaterobjekt
  310. '
  311. Sub P_ResizeObjectToObject (O_OutSource As Control, O_InSource As Control, Abstand As Integer)
  312.  
  313. O_InSource.Left = Abstand
  314. O_InSource.Top = Abstand
  315. O_InSource.Width = O_OutSource.Width - (2 * Abstand)
  316. O_InSource.Height = O_OutSource.Height - (2 * Abstand)
  317.  
  318. End Sub
  319.  
  320. Sub P_SetSysModal (F_Source As Form)
  321.  Dim Dummy As Integer
  322.  Dummy = SetSysModalWindow(F_Source.hWnd)
  323. End Sub
  324.  
  325. Sub P_SetWindowTop (F_Source As Form)
  326.     
  327.     ' Setze das Fenster (F_Source) auf die oberste Position
  328.     ' muss  nach jedem Laden des Fenster neu aufgerufen werden
  329.  
  330.     SetWindowPos F_Source.hWnd, -1, 0, 0, 0, 0, &H10 Or &H40
  331.  
  332. End Sub
  333.  
  334. Sub P_SystemInfo (WVersion As String, FreeMemory As Long, FreeResources As Integer)
  335.  
  336. Dim WinFlags As Long
  337. Dim Mode As String
  338. Dim Version As Long
  339. Dim lKBfree As Long
  340. Dim KBfree As String
  341. Dim SystemMetrics As Integer
  342.     
  343. 'fill the mode label...
  344. Mode = "Windows version "
  345.  
  346. ' Get current Windows configuration
  347. Version = GetVersion()
  348. Mode = Mode + Format(LOBYTE(LOWORD(Version)), "#") + "." + Format(HIBYTE(LOWORD(Version)), "#") + "  -  "
  349. WinFlags = GetWinFlags()
  350. If WinFlags And WF_ENHANCED Then Mode = Mode + "Enhanced Mode" Else Mode = Mode + "Standard Mode"
  351. SystemMetrics = GetSystemMetrics(SM_DEBUG)
  352. If SystemMetrics <> 0 Then Mode = Mode + " (DEBUG)"
  353. WVersion = Mode
  354.  
  355. FreeMemory = GetFreeSpace(0) \ 1024
  356. FreeResources = GetFreeSystemResources(GFSR_SYSTEMRESOURCES)
  357.  
  358. End Sub
  359.  
  360. Sub P_Warte (Sekunden)
  361.  
  362. Dim Temp_Zeit As Double
  363. Temp_Zeit = Timer
  364. Do While Not Temp_Zeit + Sekunden < Timer
  365.     DoEvents
  366. Loop
  367.  
  368. End Sub
  369.  
  370. Sub P_WritePrivatInit (ByVal Sektion$, ByVal Key$, ByVal Result$)
  371. On Error Resume Next
  372. Dim lpApplicationName$
  373. Dim lpKeyName$
  374. Dim lpString$
  375. lpApplicationName$ = Sektion$
  376. lpKeyName$ = Key$
  377. lpString$ = Result$
  378.  
  379. Dim Dummy As Integer
  380. Dim lplFileName As String
  381.  
  382. lplFileName$ = App.EXEName + ".INI"
  383. lpKeyName$ = lpKeyName$ + String$(255 - Len(lpKeyName$), 0)
  384. lpString$ = lpString$ + String$(255 - Len(lpString$), 0)
  385.  
  386. WritePrivateProfileString lpApplicationName$, lpKeyName$, lpString$, lplFileName$
  387.  
  388. End Sub
  389.  
  390. Sub show3D (Frm As Form)
  391.  
  392. ' Konstanten fⁿr die Farben
  393. Const BLACK = &H0&
  394. Const WHITE = &HFFFFFF
  395. Const GRAY = &HC0C0C0
  396. Const DGRAY = &H808080
  397.  
  398. Dim Ct As Control
  399. Dim I As Integer
  400. Dim Tx As Integer
  401. Dim Ty As Integer
  402.  
  403. ' Anzahl Twips innerhalb eines Pixels
  404. Tx = Screen.TwipsPerPixelX
  405. Ty = Screen.TwipsPerPixelY
  406. Frm.AutoRedraw = True
  407.  
  408. ' Zeichne Formular falls Border fest
  409. Frm.BackColor = &HC0C0C0
  410. If Frm.BorderStyle = 0 Or Frm.BorderStyle = 1 Or Frm.BorderStyle = 3 Then
  411.     Frm.DrawWidth = 2
  412.     Frm.Line (0, 0)-(Frm.ScaleWidth, Frm.ScaleHeight), DGRAY, B
  413.     Frm.DrawWidth = 1
  414.     Frm.Line (0, 0)-(Frm.ScaleWidth, Frm.ScaleHeight), WHITE, B
  415. End If
  416.  
  417. For I = 0 To Frm.Controls.Count - 1
  418.     Set Ct = Frm.Controls(I)
  419.  
  420.     ' Steuerelemnt <Shape>
  421.     If TypeOf Ct Is Shape Then
  422.         Ct.Visible = False
  423.         Frm.DrawWidth = 2
  424.         Frm.Line (Ct.Left, Ct.Top)-(Ct.Width + (1 * Tx) + Ct.Left, Ct.Top + Ct.Height), DGRAY, B
  425.         Frm.DrawWidth = 1
  426.         Frm.Line (Ct.Left - (1 * Tx), Ct.Top - (1 * Ty))-(Ct.Width + Ct.Left, Ct.Top + Ct.Height - (1 * Ty)), WHITE, B
  427.     End If
  428.  
  429.     ' Steuerelemnt <Label>
  430.     If TypeOf Ct Is Label Then
  431.         Frm.FontSize = Ct.FontSize
  432.         Frm.FontName = Ct.FontName
  433.         Frm.FontBold = Ct.FontBold
  434.         Ct.Visible = False
  435.         Frm.CurrentX = Ct.Left + Tx
  436.         Frm.CurrentY = Ct.Top + Ty
  437.         Frm.ForeColor = WHITE
  438.         Frm.Print Ct.Caption
  439.         Frm.CurrentX = Ct.Left
  440.         Frm.CurrentY = Ct.Top
  441.         Frm.ForeColor = BLACK
  442.         Frm.Print Ct.Caption
  443.     End If
  444.  
  445.     ' Steuerelemnt <TextBox>
  446.     If TypeOf Ct Is TextBox Then
  447.         Frm.Line (Ct.Left + (1 * Tx), Ct.Top + (1 * Ty))-(Ct.Width + Ct.Left, Ct.Top + Ct.Height), WHITE, B
  448.         Frm.Line (Ct.Left - (1 * Tx), Ct.Top - (1 * Ty))-(Ct.Width + (1 * Tx) + Ct.Left, Ct.Top + Ct.Height + (1 * Ty)), DGRAY, B
  449.         Frm.Line (Ct.Left - (2 * Tx), Ct.Top - (2 * Ty))-(Ct.Width + Ct.Left + (1 * Tx), Ct.Top + Ct.Height + (1 * Ty)), GRAY, B
  450.     End If
  451.  
  452.     ' Steuerelemnt <ListBox>
  453.     If TypeOf Ct Is ListBox Then
  454.         Frm.Line (Ct.Left + (1 * Tx), Ct.Top + (1 * Ty))-(Ct.Width + Ct.Left, Ct.Top + Ct.Height), DGRAY, B
  455.         Frm.Line (Ct.Left - (1 * Tx), Ct.Top - (1 * Ty))-(Ct.Width + (1 * Tx) + Ct.Left, Ct.Top + Ct.Height + (1 * Ty)), WHITE, B
  456.         Frm.Line (Ct.Left - (2 * Tx), Ct.Top - (2 * Ty))-(Ct.Width + Ct.Left + (1 * Tx), Ct.Top + Ct.Height + (1 * Ty)), GRAY, B
  457.     End If
  458.  
  459.     ' Steuerelemnt <ComboBox>
  460.     If TypeOf Ct Is ComboBox Then
  461.         Frm.Line (Ct.Left + (1 * Tx), Ct.Top + (1 * Ty))-(Ct.Width + Ct.Left, Ct.Top + Ct.Height), DGRAY, B
  462.         Frm.Line (Ct.Left - (1 * Tx), Ct.Top - (1 * Ty))-(Ct.Width + (1 * Tx) + Ct.Left, Ct.Top + Ct.Height + (1 * Ty)), WHITE, B
  463.         Frm.Line (Ct.Left - (2 * Tx), Ct.Top - (2 * Ty))-(Ct.Width + Ct.Left + (1 * Tx), Ct.Top + Ct.Height + (1 * Ty)), GRAY, B
  464.     End If
  465.     
  466.     ' Steuerelemnt <Line>
  467.     If TypeOf Ct Is Line Then
  468.         Ct.Visible = False
  469.         Frm.Line (Ct.X1 + (1 * Tx), Ct.Y1 + (1 * Ty))-(Ct.X2 + (1 * Tx), Ct.Y2 + (1 * Ty)), DGRAY
  470.         Frm.Line (Ct.X1, Ct.Y1)-(Ct.X2, Ct.Y2), WHITE
  471.     End If
  472.     
  473. Next I
  474.  
  475. ' Merke-Modus von Formular ausschalten
  476. Frm.AutoRedraw = False
  477.  
  478. End Sub
  479.  
  480.