Otßzky a odpov∞di

V tΘto rubrice najdete odpov∞di na svΘ otßzky, kterΘ m∙₧ete zasφlat na adresu vbtipy@atlas.cz. Pokud nebudeme znßt odpov∞∩ na n∞jakou otßzku, objevφ se v Φßsti Otßzky bez odpov∞di a budete-li znßt odpov∞∩ vy, m∙₧ete nßm ji pomocφ v²Üe uvedenΘ adresy zaslat, rßdi ji zve°ejnφme.

Otßzky a odpov∞di

Otßzky bez odpov∞di

Otßzky a odpov∞di

  Uz rok sa snazim programovat vo Visual Basic 5 a celkom mi to ide. Ale neviem prist na jednu vec. Chcel by som urobit taky program, ktory by otvoril hru Solitaire. To zatial viem spravit, ale neviem spravit to, ze ked kliknem na krizik, co je na vrchu okna, na tom modrom (ukoncit program), aby sa mi ukoncil program vo VB5.

Pokud chcete, aby se ukonΦil program, po ukonΦenφ hry Solitaire, spus¥te Solitaire pomocφ nßsledujφcφ funkce (program se po spuÜt∞nφ zastavφ) a po jejφm ukonΦenφ, tzn. po ukonΦenφ Solitaire dejte funkci na ukonΦenφ programu.

Private Type STARTUPINFO
  cb As Long
  lpReserved As String
  lpDesktop As String
  lpTitle As String
  dwX As Long
  dwY As Long
  dwXSize As Long
  dwYSize As Long
  dwXCountChars As Long
  dwYCountChars As Long
  dwFillAttribute As Long
  dwFlags As Long
  wShowWindow As Integer
  cbReserved2 As Integer
  lpReserved2 As Long
  hStdInput As Long
  hStdOutput As Long
  hStdError As Long
End Type
 
Private Type PROCESS_INFORMATION
  hProcess As Long
  hThread As Long
  dwProcessID As Long
  dwThreadID As Long
End Type
 
Private Declare Function WaitForSingleObject Lib "kernel32" _
  (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" _
  (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, _
   ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
   ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
   ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
   lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
 
Public Sub ExecCmd(cmdline$)
  Dim proc As PROCESS_INFORMATION, start As STARTUPINFO
 
  start.cb = Len(start)
 
  ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
 
  'Wait for the shelled application to finish:
  ret& = WaitForSingleObject(proc.hProcess, INFINITE)
  ret& = CloseHandle(proc.hProcess)
End Sub

Pou₧itφ potom vypadß takto:

ExecCmd("C:\WINDOWS\solitaire.exe")
End


  Mam zasifrovanu databazu urobenu v MS Access97, ako urobit aby mi ju otvoril VB5, neviem kde mam napisat heslo.

Pokud pou₧φvßte p°φmo k≤d, nap°. DAO, potom databßzi otev°ete tφmto zp∙sobem:

Dim dbMain As Database

Set dbMain=OpenDatabase("cesta",False, False,";pwd=heslo")

Pokud pou₧φvßte prvek DataControl, kter² neumφ otev°φt databßzi s heslem, musφte nejd°φve otev°φt databßzi, v nφ potom recordset a ten p°i°adit prvku DataControl:

Dim dbmain As Database, qry As Recordset

Set dbmain = OpenDatabase(App.Path & "pokus.mdb", False, False, ";pwd=heslo")
Set qry = dbmain.OpenRecordset("pokus", dbOpenDynaset)
Set Data1.Recordset = qry


  Jak ud∞lat ve formulß°i, abych nem∞l osv∞tlenΘ to X, kter²m se formulß° zavφrß. Tφm myslφm aby X bylo Disabled.

Jedin² zp∙sob, kter² m∞ napadl, je smazat ze systΘmovΘho menu polo₧ku Zav°φt, tφm se nastavφ "X" na Disabled. V p°φkladu p°edpoklßdßm menu Zav°φt na ÜestΘ pozici. Pokud je menu jinΘ, musφte zvolit jinΘ Φφslo (parametr nPosition funkce DeleteMenu) nebo mazat menu podle nßzvu.

Private Declare Function GetSystemMenu Lib "user32" _
  (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" _
  (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Private Const MF_BYPOSITION = &H400&

Private Sub Form_Load()
  Dim myMenu As Long

  myMenu = GetSystemMenu(Me.hwnd, 0)
  DeleteMenu myMenu, 6, MF_BYPOSITION
End Sub


Otßzky bez odpov∞di

  V MSDN je zmienka o pou₧itφ interfacu k objektom Windows Exploreru na vlo₧enie objektov (Listview, treeview, combo, taskbar at∩ ) do vlastn²ch aplikßciφ, ale prilo₧enΘ vzory s· pre C++. Chcem Vßs po₧iada¥ o nejakΘ moduly alebo prφklady pre pou₧itie t²chto objektov, za Φo Vßm budem ve╛mi v∩aΦn² ! Zaujφma ma hlavne zobrazenie Listview, treeview, combo z exploreru a objekty z taskbaru (tabsysview, systraj objekt, objekt hodφn a ponuky ètart pre vytvorenie novΘho typu taskbaru). Ve╛mi Vßs prosφm o pomoc.