2. ªí³æ
ªí³æ¬O§Ú̦bMicrosoft Visual Basic¤¤»{ÃѪº²Ä¤@Óª«¥ó¡CÁöµM±z¤]¯à°÷¥u¨Ï¥Î¦´Áªº¨Ï¥ÎªÌ¤¶±¡A¹³¬O©R¥O¦C¤u¨ãµ{¦¡(command-line driven utilities)¨Ó¼¶¼g¦³¥Îªºµ{¦¡¡A¦ý¬O¤j³¡¥÷ªºVisual BasicÀ³¥Îµ{¦¡³£¦Ü¤Ö¥]§t¤@©Î¦hÓªí³æ¡A¦]¦¹»Ýn¼ô±x¨äÄݩʤίS©Ê¡C
ÁöµMªí³æ¤Î±±¨î¶µ¦b¥»½è¤W¤£¦P¡A¦ý«o¦³¤@Ó«nªº¬Û³qÂI¡G¥¦Ì³£¬OVisual Basicªºª«¥ó¡A©Ò¥H¥¦ÌÅã²{ÄÝ©Ê¡B¹ï¤èªkªº¤ÏÀ³¤Î¨Æ¥óªº¤Þµo¬O¬Û¦Pªº¡CVisual Basic¥i»¡¬O¥Hª«¥ó¬°°ò¦(object-base)ªºµ{¦¡³]p»y¨¥¡A¦]¬°Visual Basicµ{¦¡¶}µoªÌªº¤u§@¥]§t¤FŪ¨ú»Pק磌¥óªºÄÝ©Ê¡B©I¥sª«¥ó¤èªk¨Ã¹ïª«¥óªº¨Æ¥ó¦^À³¡C§ó¶i¤@¨B¥i±NVisual Basicµø¬°¤@µøı¤Æµ{¦¡³]pÀô¹Ò¡A¦b¨ä¤¤¡Aª«¥óªº¥~Æ[¥i¥H¦b³]p¶¥¬q(design-time)ª½±µ¥Hµøı¤Æ¤¬°Ê¤u¨ã¨Ó©w¸q,¡A¦Ó¤£»Ýn¼g¥ô¦óªºµ{¦¡½X¡C
ªí³æ©M±±¨î¶µÅãÅS¥X²³¦hªºÄÝ©Ê¡A·í±z¦bª«¥óÂsÄý¾¹¤¤ÀË´ú¥¦Ì®É¥i¯à·|ÃhºÃn¦p¦ó¤F¸Ñ©Ò¦³Äݩʪº·N¸q¡Cn¤F¸Ñ³o¨Ç¨ä¹ê»Ýnªá¤@¬qÆZªøªº®É¶¡¡A¦ý¬O¡A¤@¬q®É¶¡¤§«á¡A±z¥i¯à·|µoı¡A¨ä¹ê³\¦h±±¨î¶µ»Pªí³æ³£¾Ö¦³¬Û¦PªºÄÝ©Ê¡C
¥Ñ©ó¤Wzªºì¦]¡A©Ò¥Hµ§ªÌ¥Î¤F¤@¨Ç¯S§Oªº¤èªk«Øºc¥»³¹¤Î«áÄò¦U³¹¡C¤j³¡¥÷ªº»y¨¥¨Ï¥Î¤â¥U³£·|¥ý¤¶²Ðªí³æ¡A¸Ôz¨C¤@Ó¤º«Øªº±±¨î¶µÃþ§O¡A¨Ã¨Ò¥Ü¨ä¯S©Êµ¥µ¥¡C¦Ó¨Ìµ§ªÌªºÆ[ÂI¦Ó¨¥¡A³oºØ¤è¦¡·|±j¢ÅªªÌ§â¨C¤@Óª«¥ó³£µø¬°¿W¥ß®×¥ó¡A¤À§O¬ã¨s¡C³oºØ¤äÂ÷¯}¸Hªº¸ê°T¥u·|¼W¥[¥þ½L¤F¸Ñªº§xÃø¡A§óÁVªº¬O¡Aªá¤O®ð°O³o¨ÇªF¦è¹ï¤F¸Ñ¹ê»Ú¹B§@ªº±¡§Î¨ÃµL¦h¤j¯q³B¡CÁ|¨Ò¨Ó»¡¡A¬°¤°»ò¦³¨Ç±±¨î¶µ¦³TabIndexÄݩʦӨS¦³TabStopÄÝ©Ê¡H¤S¬°¤°»ò¦³¨Ç±±¨î¶µ¤ä´©hWndÄݩʦӦ³¨Ç«h¤£¤ä´©¡H
´X¸g«ä¦Ò¤§«á¡Aµ§ªÌ¨M©w¸õ¥X¶Ç²Îªº»¡©ú¤è¦¡¡A¦Ó±N«ÂI©ñ¦b³\¦hªí³æ¤Î¤º«Ø±±¨î¶µ¦@³qªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó¤W¡Cªí³æªº¯S©Ê¦b¥»³¹µy«á¤]·|´£¨ì¡A²Ä¤T³¹«h¤¶²ÐVisual Basicªº¤º«Ø±±¨î¶µ¡C³oªí¥Ü±z¦b¥»³¹«e¥b¬q±N¤£·|¬Ý¨ì¥ô¦ó§¹¾ãªºµ{¦¡½d¨Ò¡A¦ý¤´·|¦³¨Çµ{¦¡½X¤ùÂ_¥Î¥H¸ÑÄÀÄݩʦp¦ó¨Ï¥Î¤Î¹ï¥Ñ¤j³¡¥÷±±¨î¶µ«¬ºA©Ò¦@¨Éªº¨Æ¥óªº¤ÏÀ³¡CÁ`Âk¤@¥y¸Ü¡A¦bVisual BasicÀô¹Ò¤¤¤u§@®É©Ò¦³ª«¥óªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥óªº§¹¾ãªí¦C¥u»ÝºV¤@ÓÁä¡G¥un«ö F2 Åã¥Üª«¥óÂsÄý¾¹¡A©Î«ö F1 ¨ú±o§¹¾ãªº»¡©ú¡C§Ú·Q±zÀ³¸Ó¤£·Q¦b¦¹«½Æ¬Ý¨º¨Ç¬Û¦Pªº¸ê°T§a!
ÁÙ¦³¨ä¥Lªºì¦]±N³q¥ÎªºÄÝ©Ê©ñ¦b¤@°_¸ÑÄÀ¡Gµo®i¨ì6.0ª©¡AVisual Basic¤w¾ú¸g¤F¦h¦¸«¤jªº§ïÅÜ¡C¨C¤@ª©³£·|·s¼W·sªº¯S©Ê¡Aªí³æ»P±±¨î¶µ¤]·|¦³§ó¦h§ó·sªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó¡Cª©¬Û®e©Ê¤@ª½¬OMicrosoftp¹ºªººn¥Ø¼Ð¡A¦]¦¹¤]¯à¤ä´©Â¦³ªº¯S©Ê¡C©Ò¥H¦bVisual BasicÀô¹Ò¤U¥i¥H¤£»Ýקï¥ô¦ó¤@¦æµ{¦¡½X¡A¤]¥i¥s¥X¨Ã°õ¦æVisual Basic 3ªº±M®×¡]°ß¤@ªº¨Ò¥~¬O·íµ{¦¡½X°Ñ·Ó¨ì¥~³¡¦s¨ú¸ê®Æ®wªºµ{¦¡®w©Î±±¨î¶µ¡^¡Cª©¬Û®e·íµM¤]¦³¨ä¯ÊÂI¡A²Ä¤@Ó´N¬O¤£Â_¼W¥[ªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó¡CÁ|¨Ò¨Ó»¡¡A°²³]¦³¤@²Õ½Æ»sªºÄÝ©Ê»P©ì¦²¦³Ãö¡A¤]¦³¤GÓ¤£¦Pªº¤è¦¡¥i³]©w¦r«¬ÄÝ©Ê¡Aµ²ªG¹ïµ{¦¡³]pªºªì¾ÇªÌ´N·|³y¦¨²V²c¡A¦Óµ{¦¡³]p¦Ñ¤â«h¥i¯à¦]¤£Ä@¦A¾Ç·s»yªk¦Ó¨Ï¥Îª©ªº¡]³q±`¬O¸ûµL®Ä²vªº¡^¯S©Ê¡C§Æ±æ±µ¤U¨Ó¹ï³q¥ÎªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó©Ò°µªº±Ôz¡A¯à¦³§U©ó©Ò¦³ÅªªÌÂç²MÆ[©À¡C
³q¥ÎÄÝ©Ê(Common Properties)
¡@
Visual Basic 6¥E¬Ý¤§¤U¦ü¥G¤ä´©¦U¦¡¦U¼Ëªºª«¥óÄÝ©Ê¡A¤£¹LÁÙ¦n¡A¨ä¹ê³\¦h¤£¦PÃþ§Oªºª«¥ó³£¦@¨É¦P¤@²ÕÄÝ©Ê¡C²{¦b¨Ó±´°Q³o¨Ç³q¥ÎªºÄÝ©Ê¡C
Left¡BTop¡BWidth¤ÎHeightÄÝ©Ê
¡@
ª«¥ó¡]ªí³æ¤Î±±¨î¶µ¡^ªº³o¨ÇÄÝ©Ê·|¼vÅT¨ä¦ì¸m©M¤j¤p¡A¦Ó³o¨Çȱ`»Pª«¥ó¦¬¯Ç¾¹¡]container¡^¬ÛÃö¡A´N¹³¿Ã¹õ¹ïªí³æ©Î¤÷ªí³æ¹ï±±¨î¶µªºÃö«Y¡C¤@±±¨î¶µ¥ç¥i¥]§t¦b¨ä¥L±±¨î¶µ¤¤¡A³o¼Ë§ÚÌ¥i»¡¨º¬O¥¦ªº¦¬¯Ç¾¹¡C¦b³oÓ¨Ò¤l¤¤¡ATop¤ÎLeftÄÝ©Ê´N»P¨ä¦¬¯Ç¾¹±±¨î¶µ¦³Ãö¡C³o¨ÇÄݩʪº¹w³]³æ¦ì¬Otwip¡]¬ù1/1440^¦T¡^¡A³oÓ³æ¦ì¯à´£¨Ñ«Ø¥ß¥ô¦ó¸ÑªR«×ªº¨Ï¥ÎªÌ¤¶±¡A±z¤]¥i¥H¸g¥Ñ³]©w¦¬¯Ç¾¹ªºScaleModeÄݩʨӧïÅÜpºâ³æ¦ì¡A¨Ò¦p¹³¯À¡]pixel¡^©Î^¦T¡A¤£¹LµLªkÅܧóªí³æ¤w¨Ï¥Îªº³æ¦ì¡A¦]¬°¥¦Ì¨ÃµL¦¬¯Ç¾¹¡Gªí³æªºLeft¡B Top¡B Width¤Î HeightÄݩʧ¡¬O¥Htwip¬°³æ¦ì¡C¦p±ýª¾twip³oÓpºâ³æ¦ì§ó¸ÔºÉªº¸ê®Æ¡A½Ð°Ñ¦Ò¥»³¹ªº,
ScaleMode Äݩʤ@¸`¡C¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤¿é¤J¼Æȸê®Æ®É¡A³q±`·|ª½±µ¦b¨ä¤÷ªí³æ¤¤²¾°Ê©Î«³]±±¨î¶µ¤j¤p¨Ó°µ³]©w¡C½Ð°O¦í³oÂI¡GVisual Basic¤w¦b ®æ¦¡ ¥\¯àªí¤¤´£¨Ñ³\¦h¤¬°Ê¦¡«ü¥O¨Ñ±z¥Î¤@Ӱʧ@§Y¥i½Õ¾ã¤j¤p¡B¹ï»ô¤Î°t¸m¦hÓ±±¨î¶µ¦ì¸m¡C·íµM¡A±z¤]¥i¥H¦b°õ¦æ¶¥¬q³z¹Lµ{¦¡½X¦s¨ú¤Îקï³o¨ÇÄÝ©Ê¥H½Õ¾ã¤j¤p¡G
'ªí³æ¼e«×¥[¿¨Ã²¾°Ê¨ì¿Ã¹õªº¥ª¤W¨¤' Form1.Width = Form1.Width * 2 Form1.Left = 0 Form1.Top = 0
½Ðª`·NÁöµM©Ò¦³±±¨î¶µ¡]¥]¬A¬Ý¤£¨£ªº¡^¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤¥iÅã¥Ü¥H¤W¥|ºØÄÝ©Ê¡A¦ý¬Ý¤£¨£ªº±±¨î¶µ¡]¨Ò¦pp®É¾¹±±¨î¶µ¡^¦b°õ¦æ¶¥¬q«h¤£¤ä´©³o¨ÇÄÝ©Ê¡A¦]¦¹¤]µLªk±qµ{¦¡½X¤¤¥hŪ¨ú©Îקï¡C
ª`·N
¨Ã«D©Ò¦³±±¨î¶µ¤@©wn¥H¤@Pªº¤è¦¡¤ä´©¥H¤W¥|ºØÄÝ©Ê¡A¨Ò¦p¹³¤U©Ô¦¡²Õ¦X²M³æ±±¨î¶µ¡]ListBox¡^ªºHeightÄݩʤ£½×¦b³]p©Î°õ¦æ¶¥¬q´N¥u¦³Åª¨ú¦Ó¤£¯à¼g¤J¡A´Nµ§ªÌ©Òª¾¡A³o¬O¥Ø«e°ß¤@Äݩʦb³]p¶¥¬qªºÄݩʵøµ¡¤¤¬Ý±o¨ì¡A¦ý«oµLªkק諸¨Ò¤l¡C³o¬O¦]¬°¤U©Ô¦¡²Õ¦X²M³æ±±¨î¶µªº°ª«×·|¨Ì±±¨î¶µªº¦r«¬Äݩʦөw¡A·í±z¦bªí³æ¤¤¼gµ{¦¡½X¨Óקï©Ò¦³±±¨î¶µªºHeightÄݩʮɡA½Ð°O±o¥H¤W³oÓ¨Ò¥~¡C
ForeColor¤ÎBackColorÄÝ©Ê
¡@
¤j³¡¥÷¬Ý±o¨£ªºª«¥ó³£¦³ForeColor¤ÎBackColor¤GÓÄÝ©Ê¡A³o¤GÓÄÝ©Ê·|¼vÅT¤å¦r¥»¨¤ÎI´ºªºÃC¦â¡C³¡¥÷±±¨î¶µ¡]¨Ò¦p¡G±²¶b¡^ªºÃC¦â¬O¥ÑMicrosoft Windows±±¨î¡A¦]¦¹¦bÄݩʵøµ¡´N¬Ý¤£¨ìForeColor¤ÎBackColor¤GÓÄÝ©Ê¡C¥t¥~¦³¨Çª¬ªp¬O¡A³o¤GÓÄݩʪº®ÄªG·|ÀH¨ä¥LÄݩʧïÅÜ¡A¨Ò¦p¡G¦pªG³]©w¤å¦r¼ÐÅÒ±±¨îªºBackStyleÄÝ©ÊȬ°0¢w³z©ú¡A«h¸Ó¤å¦r¼ÐÅÒ±±¨î¶µªºBackColor´N·|¨S¦³®ÄªG¡C«ü¥O«ö¶s±±¨î¶µ¤]«D±`¯S§O¡A¨ä¦³BackColorÄݩʦý¨S¦³ForeColorÄÝ©Ê¡A¥B¨äI´ºÃC¦â¶È¦bStyleÄÝ©Êȳ]©w¬°1¢w¹Ï§Î¤~¦³§@¥Î¡]¦Ó¦]¬° Style Äݩʹw³]Ȭ°0-¼Ð·Ç¡A©Ò¥H¤@¯ë±¡ªp¤U¡AµL½×¦bBackColor¤¤¦p¦óקﳣ¤£·|¦³§@¥Î¡^¡C
¦bÄݩʵøµ¡¤¤³]©w¥H¤W¨ä¤¤¤@ºØÄÝ©Ê¡A³£¥i¿ï¾Ün¼Ð·Çµøµ¡¦â±m¡B¨t²Î°t¦â¶Åҩνզâ½L¶ÅÒ¨Ó¦Ûq¦â±m¡A½Ð°Ñ¦Ò¹Ï2-1¡Cµ§ªÌªº«Øij¬O°£«D¥t¦³ì¦]¤@©wn¨Ï¥Î¦Ûq¦â±m¡A§_«h³Ì¦n¨Ï¥Î¼Ð·Ç¦â±m¡C¨t²Î°t¦â¦b¥ô¦óµøµ¡ª©ªº¾÷¾¹³£¯à¨}¦nÅã¥Ü¡A¥B³q±`·|²Å¦X±z«È¤áªº³ß¦n¡A¨ÃÅý±zªºÀ³¥Îµ{¦¡¬Ý°_¨Ó¦b¨t²Î¤¤¾ã¦X±o¬Û·í¦n¡C²Ä¤GÓ«Øij¬O¦pªG·Q¨Ï¥Î¦Ûq¦â±m¡A«h°µ¤@Ó©T©wªº¦â±m¬[ºcÀ³¥Î¦b¾ãÓÀ³¥Îµ{¦¡¤¤¡C²Ä¤TÓ«Øij«h¬O¡G¤d¸U¤£n¦b¦P¤@ªí³æ¤¤¦P®É¨Ï¥Î³o¤GºØ¤è¦¡¡A¹ï¦P¤@Ó±±¨î¶µ¤]¤£n¦bForeColorÄݩʤ¤¨Ï¥Î¼Ð·Ç°t¦â¦Ó¦bBackColor¤¤¨Ï¥Î¦Ûq¦â±m¡]¤Ï¤§¥çµM¡^¡A¦]¬°³o¼Ë¥i¯à·|§ïÅܨt²Î½Õ¦â½L¦Ó¨Ï±±¨î¶µ§¹¥þ¬Ý¤£¨ì¡C
¦³«Ü¦h¤èªk¥i¦bµ{¦¡½X¤¤«ü©w°t¦â¡CVisul Basic¦b³]p¶¥¬qªºÄݩʵøµ¡ªº¨t²Î°t¦â¶ÅÒ¤¤´£¨Ñ¤@²Õ²Å¸¹±`¦¡¥H¹ïÀ³©Ò¦³ªºÃC¦â¡G
'¨ÏLabel1¥H©Ò¿ïªºª¬ºA¥X²{¡C Label1.ForeColor = vbHighlightText Label1.BackColor = vbHighlight
ªí2-1¦C¥X¤F©Ò¦³²Å¸¹±`¼Æ¡C¤]¥i¥H¦bÂsÄýª«¥óµøµ¡¤¤ÂsÄý¡A¦b³Ì¥ªÃ䪺¤U©Ô¦¡²M³æ¤¤«ö¤USystemColor±`¦¡«á¡A¿ï¾Ü All libraries ©Î¤WºÝªº¤U©Ô¦¡²Õ¦X²M³æ±±¨î¶µ¤¤ªº VBRUN ¡C½Ðª`·N³o¨Ç±`¼ÆªºÈ³£¬Ot¼Æ¡C
¡@
¹Ï2-1¬O¦b³]p¶¥¬q³]©w ForeColor ¤Î BackColor ÄݩʤGºØ¤£¦Pªº¤èªk¡C |
±`¼Æ | ¤Q¤»¶i¦ì¼ÆÈ | »¡©ú |
---|---|---|
vb3DDKShadow | &H80000015 | ³Ì²`ªº³±¼v |
vb3Dface | &H8000000F | ¥ßÅéÅã¥Ü¶µ¥Øªº¸û²`³±¼v |
vb3Dhighlight | &H80000014 | ¥ßÅéÅã¥Ü¶µ¥Øªº¤Ï¥Õ¦â±m |
vb3Dlight | &H80000016 | ¥ßÅéÅã¥Ü¶µ¥Øªº¸û²L¤Ï¥Õ¦â±m (¦¸©óvb3DHilight)¡C |
vb3Dshadow | &H80000010 | µøµ¡ªº³±¼v¦â±m |
vbActiveBorder | &H8000000A | ¨Ï¥Î¤¤µøµ¡ªº®Ø½u¦â±m |
vbActiveTitleBar | &H80000002 | ¨Ï¥Î¤¤µøµ¡ªº¼ÐÃD¦â±m |
vbActiveTitleBarText | &H80000009 | ²{¥Î¼ÐÃD¡B½Õ¾ã¤j¤p¤è¶ô¥H¤Î±²¶b½b¸¹¤è¶ô¤¤ªº¤å¦r |
vbApplicationWorkspace | &H8000000C | ¦h«¤å¥ó¤¶± (MDI) À³¥Îµ{¦¡ªºI´º¦â±m |
vbButtonFace | &H8000000F | «ö¶sªºªí±¦â±m |
vbButtonShadow | &H80000010 | «ö¶sªº³±¼v¦â±m |
vbButtonText | &H80000012 | «ö¶sªº¤å¦r¦â±m |
vbDesktop | &H80000001 | ®à±¦â±m |
vbGrayText | &H80000011 | ¦Ç¦â (§e¼È¤îª¬ºAªº) ¤å¦r |
vbHighlight | &H8000000D | ±±¨î¶µ¤¤¿ï¨ú¶µ¥ØªºI´º¦â±m |
vbHighlightText | &H8000000E | ±±¨î¶µ¤¤¿ï¨ú¶µ¥Øªº¤å¦r¦â±m |
vbInactiveBorder | &H8000000B | «D¨Ï¥Î¤¤µøµ¡ªº®Ø½u¦â±m |
vbInactiveCaptionText | &H80000013 | «D¨Ï¥Î¤¤¼ÐÃDªº¤å¦r¦â±m |
vbInactiveTitleBar | &H80000003 | «D¨Ï¥Î¤¤µøµ¡ªº¼ÐÃD¦â±m |
vbInactiveTitleBarText | &H80000013 | «D²{¥Îµøµ¡¼ÐÃD¡B½Õ¾ã¤j¤p¤è¶ô¥H¤Î±²¶b½b¸¹¤è¶ô¤¤ªº¤å¦r |
vbInfoBackground | &H80000018 | ¤u¨ã´£¥ÜªºI´º¦â±m |
vbInfoText | &H80000017 | ¤u¨ã´£¥Üªº¤å¦r¦â±m |
vbMenuBar | &H80000004 | ¥\¯àªíI´º¦â±m |
vbMenuText | &H80000007 | ¥\¯àªí¤¤ªº¤å¦r¦â±m |
vbScrollBars | &H80000000 | ±²¶b¦Ç¦â°Ï°ìªº¦â±m |
vbTitleBarText | &H80000009 | ²{¥Î¼ÐÃD¡B½Õ¾ã¤j¤p¤è¶ô¥H¤Î±²¶b½b¸¹¤è¶ô¤¤ªº¤å¦r¦â±m |
vbWindowBackground | &H80000005 | µøµ¡I´º¦â±m |
vbWindowFrame | &H80000006 | µøµ¡¥~®Ø¦â±m |
vbWindowText | &H80000008 | µøµ¡¤¤ªº¤å¦r¦â±m |
ªí2-1¬OVisual Basic©Ò¥Îªº¨t²ÎÃC¦â¤§±`¼Æ¡C |
«ü¬£¦Ûq¦â±m®É¡A¥i¥H¥ÎVisual Basic©w¸qªºÃC¦â±`¼Æ¨Ó©w¸q¤@¨Ç±`¨£ªº¦â±m¡]vbBlack¡B vbBlue¡B vbCyan¡B vbGreen¡B vbMagenta¡BvbRed¡B vbWhite¡B and vbYellow¡A©Î¨Ï¥Î¤Q¶i¦ì¤Î¤Q¤G¶i¦ìªº±`¼Æ¡G
' ¥H¤U¤G³¯±Ô¦¡¬O¬Û¦Pªº¡C Text1.BackColor = vbCyan Text1.BackColor = 16776960 Text1.BackColor = &HFFFF00
±z¤]¥i¥H¨Ï¥ÎRGB¨ç¼Æ¤¤¬õ¦â¡Bºñ¦â¡B¤ÎÂŦ⤸¥óªº²Õ¦X¨Ó«Ø¥ßÃC¦âªºÈ¡C³Ì«á¡A¬°¤F¯à²¤Æ²¾´Ó¬J¦³ªºQuickBasicÀ³¥Îµ{¦¡¡AVisual Basic¤]¤ä´©QBColor¨ç¼Æ¡G
' ¥H¤U³¯±Ô¦¡»P¤W¦¡¬O¬Û¦Pªº¡C Text1.BackColor = RGB(0, 255, 255) ' red, green, blue values Text1.BackColor = QBColor(11)
FontÄÝ©Ê
¡@
ªí³æ¤Î±±¨î¶µ©Ò¯àÅã¥Üªº¦r¦ê³£¦³FontÄÝ©Ê¡C¦b³]p¶¥¬q¡A±z¥i¨Ï¥Î¤@¯ëªº¤å¦r¹ï¸Ü¤è¶ô¨Ó³]©w¦r«¬ÄÝ©Ê¡A½Ð°Ñ¦Ò¹Ï2-2¡CµM¦Ó¦b°õ¦æ¶¥¬q«h¨S¨º»ò²³æ¡A¦]¬°Font¬O¤@ӽƦX¦¡ªºª«¥ó¡A©Ò¥H¥²¶·¤À§O«ü¬£ÄÝ©Ê¡CFontª«¥ó¦³Name¡BSize¡BBold¡BItalic¡BUnderline¤ÎStrikethroughÄÝ©Ê¡C
Text1.Font.Name = "Tahoma" Text1.Font.Size = 12 Text1.Font.Bold = True Text1.Font.Underline = True
¡@
¹Ï2-2 ³]p¶¥¬q¤¤¡AFont¹ï¸Ü¤è¶ô¯à¥ß§YÅý±zקï©Ò¦³¦r«¬ÄݩʨåBª½±µ¹wÄýµ²ªG¡C |
¤p¯µ³Z
¥i¥H¨Ï¥ÎSet«ü¥O¨Ó«ü¬£±±¨î¶µ©Ò¦³ªºFontª«¥ó¡]¦]¦¹¤£»ÝÓ§O³]©w¦r«¬ÄÝ©Ê¡^¡A½Ð°Ñ¦Ò¦p¤Uµ{¦¡½X¡G
' «ü¬£Text2»PText1¬Û¦Pªº¦r«¬¡C' Set Text2.Font = Text1.Font
¤W±ªº¨Ò¤l«Ü©úÅã¦a¥i¥H¬Ý¥X¦p¦ó¥Îµ{¦¡½X¨Ó¹ï¤GÓ±±¨î¶µ«ü¬£¬Û¦PªºFontª«¥ó(objec)¡C³oªí¥Ü¦pªG¤§«án§ïÅÜText1ªº¦r«¬¡AText2¤]·|¸òµÛ§ï¡C¦¹§@¥Î»PFontª«¥óªº¥»½è¬Û·í½Õ¦X¡A±N¦b ²Ä¤»³¹ ·|¦³§ó¸ÔºÉªº¤¶²Ð¡C±z¥i¥H¦n¦n§Q¥Î³o¤@Ӥ覡¡]¨Ò¦p¦bªí³æ¤¤©Ò¦³±±¨î¶µ³£n¨Ï¥Î¦P¤@¦r«¬®É¡^¡C
Visual Basic 6¤´Ä~Äò«O¦³Âª©ªº¤@¨ÇFontÄÝ©Ê¡A¨Ò¦p¡G FontName¡BFontSize¡B FontBold¡BFontItalic¡BFontUnderlin¤ÎFontStrikethru¡A¤£¹L¦]¬°¥L̤£·|¥X²{¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤¡A©Ò¥H¥u¯à³z¹Lµ{¦¡½X¨Ó°µ×§ï¡A±z¾¨¥i¨Ï¥Î±z³ßÅwªº»yªk¡A¦]¬°³o¤GӧΦ¡¬O§¹¥þ¥i¬Û¤¬´À´«ªº¡A¦b¥»®Ñ¤¤¡A¤j³¡¥÷§Ú³£¬O¨Ì´`·sªºª«¥ó¾É¦V(object-oriented)ªº»yªk¡C
Font.SizeÄÝ©Ê¡]©ÎFontSizeÄÝ©Ê¡^¬O«Ü¯S²§ªº¡A¦]¬°¦b¤@¯ëªº±¡ªp¤U¡AµLªk½Tª¾Visual Basic¯à§_«Ø¥ß¯S©wªº¦r«¬¤j¤p¡A¯S§O¬O·í¤£¨Ï¥ÎTrueType¦r«¬®É¡A¥Ñ¥H¤Uªºµ{¦¡½X¥i¨£¤@¯ë¡G
Text1.Font.Name = "Courier" Text1.Font.Size = 22 Print Text1.Font.Size ' Prints 19.5
½Ðª`·N§Y¨Ï«ü©w¯S©w¤£¥i±oªº¦r«¬¤j¤p¤]¤£·|¥X²{¿ù»~¡C
ª`·N
¦b¤@¯ëªº±¡ªp¤U¡A¦b«ü©wµL®Äªº¦r«¬®É¡AVisual Basic¤]¤£·|¥X²{¿ù»~¡C¦b¦¹±¡ªp¤U¡Aµ²ªG·|Åܱo¦³¨Ç¤£¥i¹w´Á¡A½Ð¸Õ¬Ý¥H¤Uªºµ{¦¡½X¡G
' ĵ§i¡G¦b±zªº¨t²Î¥i¯à·|¥X²{¤£¦Pªºµ²ªG¡C Print Font.Name ' Displays "Ms Sans Serif" Font.Name = "xyz" Print Font.Name ' Displays "Arial"
Caption¤ÎTextÄÝ©Ê
¡@
CaptionÄݩʬO¦b±±¨î¶µ¤º³¡¡]©Î¦bªí³æªº¼ÐÃD¦C¡^¤¤Åã¥Üªº¤@²Õ¦r¦ê¡A¦Ó¨Ï¥ÎªÌ¤£¯àª½±µ×§ï¡C¬Û¤Ï¦a¡ATextÄÝ©Ê«h¹ïÀ³¨ì±±¨î¶µªº¡u¤º®e¡v¦Ó¥B¥i¥H¥Ñ¨Ï¥ÎªÌª½±µ½s¿è¡C¦]¬°¤ºqªº±±¨î¶µ³£¤£¥i¯à¦P®É¦³Caption¤ÎText¤GÓÄÝ©Ê¡A©Ò¥H¦b¹ê°È¤W¥²»Ý¥ÑÄݩʵøµ¡¤¤¨Ó¬Ý¬Ý¥Ø«e¤u§@ªº¹ï¶H¬O¨º¤@Ó¡G¤å¦r¼ÐÅÒ¡B«ü¥O«ö¶s¡B®Ö¨ú¤è¶ô¡BOptionButton¡BData¡B¥H¤ÎFrame±±¨î¶µªºCaptionÄÝ©Ê©ÎTextBox¡BListBox¡Band ComboBox±±¨î¶µªºTextÄÝ©Ê¡C
CaptionÄݩʯS§Oªº¦a¤è¦b©ó¨ä§â¡u&¡v¦r¤¸¯Ç¤J°µ±±¨î¶µªº§Ö³tÁä¡C¦ÓTextÄݩʳQ·í°µ¬O±±¨î¶µªº¹w³]È¡A¥i¦bµ{¦¡½X¤¤§R§ï¡C
' ¥H¤Uªº³¯±Ô¦¡¬O¬Û¦Pªº Text2.Text = Text1.Text Text2 = Text1
»¡©ú
¦bµ{¦¡½X¤¤n«ü©w©Î¬O¬Ù²¤¹w³]ÈÄݩʪº¦WºÙ¨ú¨M©óÓ¤Hªº°¾¦n¡A³q±`§Ú·|¸ÕµÛ¦bµ{¦¡½X¤¤¥[¤W©Ò¦³«ü©wªºÄݩʦWºÙªº°Ñ·Ó¡A¦p¦¹¤@¨Ó¡Aµ{¦¡½X·|Åã±o¸û²M´·©öÀ´¡C¤£¹L¡A¦pªGµ{¦¡½X«Üªø¡An«ü©w©Ò¦³¹w³]ÄݩʦWºÙ«h¥i¯à¨Ïµ{¦¡½XÅܱo¤£¨ã¥iŪ©Ê¡A¦Ó¥B¥i¯à·|»Ýn¤ô¥±²°Êµ{¦¡½Xµøµ¡¡C¥»®Ñ±N·|¨Ì´`³oÓ¦Ò¶q¡A©Ò¥H¤j³¡¥÷ªº®É«J§Ú·|«ü©w¹w³]ÄݩʦWºÙ¡A¦Ó¦pªGµ{¦¡½X¤Óªøªº¸Ü«h·|¬Ù²¤¡C
¦b°Q½×³oÓ½ÒÃD®É¡Aµ§ªÌµo²{³\¦hµ{¦¡³]p®v»~¥H¬°¦pªG¨Ï¥Î¹w³]ªºÄÝ©Ê¥i¥H¥[§Öµ{¦¡½Xªº°õ¦æ³t«×¡A¨ä¬O³o¬OVisual Basic 3®É¥N´Ý¯d¤U¨ÓªºÆ[©À¡A¦Ó¨ìVisual Basic 4®É´N¤w§ïÅܱ±¨î¶µªº¤º³¡¹ê§@¤è¦¡¤F¡C
¤jÅé¤W¦Ó¨¥¡A¦pªG¤@±±¨î¶µÅã¥ÜTextÄÝ©Ê¡A´N·|¤ä´©SelText¡B SelStart¡B¤ÎSelLengthÄÝ©Ê¡A³o¨ÇÄÝ©Ê·|¶Ç¦^¥Ø«e¦b±±¨î¶µ¤¤¿ï¨úªº¤å¦r³¡¥÷¤§¬ÛÃö¸ê°T¡C
Parent¤ÎContainerÄÝ©Ê
¡@
ParentÄݩʬO¶È¦b°õ¦æ¶¥¬q¤~¦³ªºÄÝ©Ê¡]§Y¦bÄݩʵøµ¡±N¤£·|¬Ý¨ì¦¹¤@ÄÝ©Ê¡^¡A³oÓÄÝ©Ê·|¶Ç¦^¥]¬A¦¹±±¨î¶µ¤§ªí³æªº°Ñ·Ó¡CContainerÄݩʤ]¬O¦b°õ¦æ¶¥¬q¤~¦³ªºÄÝ©Ê¡A¦Ó¨ä¶Ç¦^ªº¬O±±¨î¶µ¦¬¯Ç¾¹ªº°Ñ·Ó¡C³o¤GÓÄÝ©Ê©¼¦¹¬ÛÃö ¡A·í±±¨î¶µª½±µ©ñ¸m¦bªí³æªí±¤W¡A³o¤GÓÄݩʱN·|¶Ç¦^¦P¤@ª«¥ó¡]¤÷ªí³æ¡^¡C
¦pªG·Q±N¤@Ó±±¨î¶µ±q¤@Óªí³æ²¾°Ê¨ì¥t¤@Óªí³æ¤W¡A¥i¥H¸ÕµÛ¨Ï¥ÎParentÄÝ©Ê¡]¦¹ÄݩʬO°ßŪªº¡^¡A«ü¬£¤@¤£¦PªºÈ¨ìContainerÄÝ©Ê¡]¦¹ÄݩʬO¥iŪ¼gªº¡^¤¤«h¥i²¾°Ê±±¨î¶µ¨ì¥t¤@Ó¦¬¯Ç¾¹¡A¦Ó¦]¬°«ü¬£ªº¤£¬O³æ¯ÂªºÈ¦Ó¬Oª«¥ó©Ò¥H¥²»Ý¨Ï¥ÎSetÃöÁä¦r¡G
' ²¾°ÊText1¨ìPicture1¦¬¯Ç¾¹¡G Set Text1.Container = Picture1 ' Move it back on the form's surface. Set Text1.Container = Form1
Enabled¤ÎVisibleÄÝ©Ê
¡@
¦b°õ¦æ¶¥¬q¡A©Ò¦³±±¨î¶µ¤Îªí³æªº¹w³]ȳ£¬O¬Ý±o¨ì¦Ó¥B¬O¥i§@¥Îªº¡C¦ý¦³®É¤]·|»Ýn±N¨äÁôÂéγ]¦¨¤£¥i§@¥Îªºª¬ºA¡CÁ|Ó¨Ò¤l¡A°²³]²{¦bn¨Ï¥ÎÁôÂêºDriveListBox±±¨î¶µ¨Ópºâ¨t²Î¤¤¦³¦h¤ÖºÏºÐ¾÷¡A¦]¦¹»Ý¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤³]©wDriveListBox±±¨î¶µªºVisibleÄݩʬ°False¡A¤£¹L³q±`¤]¥i¥H¦b°õ¦æ¶¥¬q¨ÓÅܧó³o¨ÇÄÝ©Ê¡G
' ·í¨Ï¥ÎªÌÂI¿ïCheck1 CheckBox±±¨î¶µ®É¨ÏText1¦³§@¥Î©ÎµL§@¥Î Private Sub Check1_Click() Text1.Enabled = (Check1.Value = vbChecked) End Sub
µL§@¥Îªº±±¨î¶µ¤£·|¹ï¨Ï¥ÎªÌªº°Ê§@¦³¦^À³¡A¦ý¨ä¹ê¥LÁÙ¬O¥þ¥\¯à¦a¨Ã¥B¤´¥i³z¹Lµ{¦¡½X¨Ó°µ½Õ¾ã¡C¬Ý¤£¨ìªº±±¨î¶µ´N¬O³]©w¬°µL§@¥Î¡A©Ò¥H¤£»Ý¥h³]©w³o¤GÓÄÝ©ÊȬ°False¡C©Ò¦³ªº·Æ¹«¨Æ¥ó¹ïµL§@¥Î©Î¬Ý¤£¨ìªº±±¨î¶µ³£·|Âà¨ì¤U¼h¦¬¯Ç¾¹©Îªí³æ¥»¨¡C
¦pªG¤@ª«¥ó¬O¥t¤@ª«¥óªº¦¬¯Ç¾¹¡]¨Ò¦p¡Gªí³æ¬O¨ä±±¨î¶µªº¦¬¯Ç¾¹¡A¦Ó®Ø¬[±±¨î¶µ«h¥i¬O¤@²ÕOptionButton±±¨î¶µªº¦¬¯Ç¾¹¡^¡A³]©w¨äVisible©ÎEnabledÄÝ©Ê·|¶¡±µ¼vÅT¨ä©Ò¦¬¯Çª«¥óªºª¬ºA¡C³oÓ¯S©Ê¥i´î¤Ö쥻±o¼gªº¤@²Õ¦³§@¥Î©ÎµL§@¥Îªº¬ÛÃö±±¨î¶µªºµ{¦¡½X¼Æ¶q¡C
¤p¯µ³Z
¤j³¡¥÷ªº±±¨î¶µ·í¬°µL§@¥Îª¬ºA®É·|§ïÅܨä¥~Æ[¡C¤@¯ë»¡¨Ó¡A³o¬Oӫܦ³¥Îªº¥\¯à¡A¦]¬°¨Ï¥ÎªÌ¥i¤@¥Ø¤FµM¨ì©³¨º¤@Ó±±¨î¶µ¬O¥i¥H§@¥Îªº¡C¦pªG±z¤@©w»Ýn¨Ï±±¨î¶µµL§@¥Î¡A¦ý¤S¥²»ÝÅý¥L¬Ý°_¨Ó¹³¬O¦b¥i§@¥Îªºª¬ºA¡A´N¥i¥H±N¦¹±±¨î¶µ©ñ¦b¤@Ó¦¬¯Ç¾¹¤¤¡]¨Ò¡G®Ø¬[©Î¹Ï¤ù¤è¶ô¡^¡AµM«á³]©w¦¬¯Ç¾¹ªºEnabledÄݩʬ°False¡C Visual Basic·|Åý©Ò¦³¦¬¯Çªº±±¨î¶µ³£µL§@¥Î¡A¦ý¬Ý°_¨Ó¹³¬O¦³§@¥Î(Enabled)ªºª¬ºA¡C³oÓ¤p§Þ¥©¦b±z¦P®É¤]³]©w¦¬¯Ç¾¹ªºBorderStyleÄݩʬ°0-None®É·|§ó¦n¥Î¡C
¦³¨Çµ{¦¡³]p®v·|³]©wTextBox©ÎComboBox±±¨î¶µªºEnabledÄÝ©ÊȬ°False¡A©w¨ä¬°°ßŪ¼Ò¦¡¡A³o¤]¬OVisual Basic 3©Î§ó¦ªºª©¥»¤¤ªº²ßºD¡A¦Ó²{¦bªº±±¨î¶µ¥t¦³¤@LockedÄÝ©Ê¡A·íȬ°True®É¡A±±¨î¶µ´N¬O¥i§@¥Îªº¦ý¨Ï¥ÎªÌµLªkקï¥LªºTextÄÝ©Ê¡C
hWndÄÝ©Ê
¡@
hWndÄݩʨ䣦bÄݩʵøµ¡¤¤¡A¦]¬°¨äÈ¥u¦b°õ¦æ¶¥¬q¤~¥i§Q¥Î¨ì¡C¥¦¤]¬O¤@Ó°ßŪªºÄÝ©Ê¡A¦]¦¹µLªk«ü¬£¥¦ªºÈ¡ChWndÄÝ©Ê·|¶Ç¦^Windows¤º³¡¥Î¨Ó¿ë»{±±¨î¶µªº32¦ì¤¸¾ã¼ÆÈ¡A¡C³oÓȦb¼Ð·ÇªºVisual Basicµ{¦¡³]p¬OµL·N¸qªº¡A¦ý¦b©I¥sWindows API±`¼Æ¡]½Ð°Ñ¦Ò ªþ¿ýA ¡^®É«o¤S«D±`¦n¥Î¡CÁöµM¥i¯à¥Î¤£¨ì¦¹¤@ÄÝ©Ê¡A¤£¹L¤]±o¤F¸Ñ¨Ã«D©Ò¦³±±¨î¶µ³£¤ä´©³oÓÄÝ©Ê¥H¤Î¬°¤°»ò¡C
Visual Basic±±¨î¶µ¡]¥]¬AVB¥»¨¤º§tªº¤Î¥~³¡Microsoft ActiveX¤GºØ±±¨î¶µ¡^¡A¥i¥H³Q¤À¬°¤G¤jÃþ§O¡G¼Ð·Ç±±¨î¶µ¤Î«Dµøµ¡¡]©ÎLightWeight¡^±±¨î¶µ¡C¤GªÌ¶¡ªº¤£¦P¥i³z¹LPictureBox¡]¼Ð·Ç±±¨î¶µ¡^¤ÎImage¡]µLµøµ¡±±¨î¶µ¡^¤GÓ±±¨î¶µªº¤ñ¸û±oª¾¡CÁö«h¥¦Ì¥E¬Ý¤§¤U«Ü¹³¡A¦ý¦b¨äI«á¥i¬O§¹¥þ¤£¦P¡C
¦bªí³æ¤¤©ñ¸m¼Ð·Ç±±¨î®É¡AVisual Basic·|n¨D¾Þ§@¨t²Î«Ø¥ß±±¨î¶µÃþ§Oªº°õ¦æÓÅé¡AWindows¤]·|¹ï¦¹±±¨î¶µ°µ¤º³¡³B²z«á¦A¦^¶Çµ¹Visual Basic¡AµM«áµ{¦¡»y¨¥¦A³z¹LhWndÄÝ©ÊÅã¥Ü¥X¨Óµ¹µ{¦¡³]p®v¡C³o¤@³s¦êVisual Basic¹ï¦¹±±¨î¶µªº§@¥Î¡]¤j¤p¡B¦r«¬³]©wµ¥µ¥¡^¤~¯u¥¿¦a±ÂÅvµ¹Windows³B²z¡C·íÀ³¥Îµ{¦¡±Ò°Ê¤@¨Æ¥ó¡]¨Ò¦p¡G«³]¤j¤p¡^¡AVisual Basic°õ¦æ®É·|©I¥s¤º³¡ªºWindows API¨ç¼Æ¨Ã±N¶Çµ¹¥¦¤@ÓÃѧO½X¡A¦p¦¹¤@¨ÓWindows´N·|ª¾¹D¨º¤@Ó±±¨î¶µ·|³Q¼vÅT¨ì
¦ÓLightweight±±¨î¶µ¡]¨Ò¦p¡GImage±±¨î¶µ¡^»PWindowsª«¥ó«h¥þµMµLÃö¡A¦Ó¬O§¹¥þ¥ÑVisual BasicºÞ²z¡C´N¬Y¤è±¦Ó¨¥¡A¨ä¹êVisual Basic¥u¬O¼ÒÀÀ±±¨î¶µªº¦s¦b¡G¥¦·|°lÂÜlightweight±±¨î¶µ¨Ã¥B¨C·íªí³æ§ó·s®É´N·|«µe¤@¦¸¡C¤]¦]¬°¨ä¨S¦³¥ô¦óWindows¬ÛÃöªºÃѧO½X¡A¬Æ¦ÜWindows®Ú¥»¤£ª¾¹D¦³Ó±±¨î¦b¨ºùØ¡A©Ò¥Hlightweight±±¨î¶µ¤£·|¦³hWndÄÝ©Ê¡C
¹ê°È¤WªºÆ[ÂI¦Ó¨¥¡A¼Ð·Ç±±¨î¶µ¤Îlightweight±±¨î¶µ¶¡ªº°Ï§OÀ³»¡¬O¡G«eªÌ·|®ø¯Ó¨t²Î¸ê·½¤Î°O¾ÐÅé¦Ó«áªÌ«h¤£·|¡C©Ò¥HÀ³¸Ó±`n§Q¥Îlightweightªº±±¨î¶µ¨Ó¥N´À¼Ð·Ç±±¨î¶µ¡CÁ|¨Ò¨Ó»¡¡A¨Ï¥ÎImage±±¨î¶µ¦Ó¤£n¥ÎPictureBox±±¨î¶µ¡A°£«D¬O»Ýn¥Î¨ìPictureBoxªº¯S©Ê¡C¥Î100ÓPictureBox±±¨î¶µªºªí³æn¤ñ¥Î100ÓImage±±¨î¶µªºªí³æ¡A¦b¸ü¤J®Én¦h¤W10¿ªº®É¶¡¡A§Æ±æ³oÓ»¡©ú¨Ï±z§ó¤F¸Ñ¦b¨ä¹ê°È¤Wªº·N¸q¡C
nª¾¹D¤@Ó±±¨î¶µ¬O§_¬°lightweight¡A¥un¬Ý¥L¬O§_¤ä´©hWndÄݩʧY¥i¡C¦pªG¤ä´©¡A¨º¥¦¥²µM¬O¤@ӼзǪº±±¨î¶µ¡Cª«¥óÂsÄý¾¹Åã¥ÜªºTextBox¡BCommandButton¡BOptionButton¡BCheckBox¡BFrame¡BComboBox¤ÎOLE±±¨î¶µ¡AÁÙ¦³±²¶b¤ÎListBox±±¨î¶µ¤Î¨ä©Ò¦³ªºÅܰʳ£¬O¼Ð·Çªº±±¨î¶µ¡C¦ÓLabel¡BShape¡BLine¡BImage¤ÎTimer±±¨î¶µ¨ÃµLhWndÄÝ©Ê«hÀ³¸Ó¥i¦Ò¼{¨ä¬°lightweight±±¨î¶µ¡A¤£¹L±oª`·N¦b¥~³¡ªºActiveX±±¨î¶µ¤¤°ßµLhWndÄÝ©Ê¡A¦ý¤£¯à±N¤§Âk¬°«Dµøµ¡ªº¡A¦]¬°³oÓ±±¨î¶µªº³]¥ß´N¬O¤£§Æ±æ±Nµøµ¡ªºÃѧO½XÅã²{©ó¥~ªºì¬G¡C¦b¥»³¹«áÄòÁ¿zÃö©óZorder¤èªk®É·|¹ï¦¹¤GÃþÄݩʦA°µ²`¤J¤¶²Ð¡C
TabStop¤ÎTabindexÄÝ©Ê
¡@
¥i¥H±µ¨ü¿é¤JµJÂI(focus)ªº±±¨î¶µ³£¦³TabStopÄÝ©Ê¡C¤j³¡¥÷©T¦³ªº±±¨î¶µ³£¤ä´©¦¹¤@ÄÝ©Ê¡A¥]¬ATextBox¡BOptionButton¡BCheckBox¡BCommandButton¡BOLE¡BComboBox¡B¤GÓ±²¶b¡BListBox±±¨î¶µ¤Î¨ä©Ò¦³ªºÅܼơC¤jP¤W¦Ó¨¥¡A©T¦³ªºlightweight±±¨î¶µ¨Ã¤£¤ä´©¦¹¤@ÄÝ©Ê¡A¦]¬°¨ä¥Ã»·¤£·|¦¬¨ì¿é¤JµJÂI¡C³oÓÄݩʪº¹w³]Ȭ°True¡A¤£¹L¤£½×¬O¦b°õ¦æ©Î³]p¶¥¬q³£¥i¦A³]©w¬°False¡C
¤ä´©TabStopÄݩʪº±±¨î¶µ¦P®É¤]·|¤ä´©TabIndexÄÝ©Ê¡A³o¤GÓÄÝ©Ê·|¼vÅTTabªº¦¸§Ç¡A·N§Y·í¨Ï¥ÎªÌ«ÂЫö¤UTabÁä®É¡A·|¼vÅT±±¨î¶µ¥X²{ªº¶¶§Ç¡]¥t½Ð°Ñ¦Ò²Ä¤@³¹¤¤ ¡q³]©wTab¦¸§Ç¡r ªº³¡¥÷¡^¡CLabel¤ÎFrame±±¨î¶µÁöµM¤]¤ä´©TabIndexÄÝ©Ê¡A¤£¹L¦]¬°³o¤GÓ±±¨î¶µ¨Ã¤£¤ä´©TabStopÄÝ©Ê¡A¨ä©Ò²£¥ÍªºÅܤƬO·í¨Ï¥ÎªÌÂI¿ïLabel©ÎFrame±±¨î¶µ¡]©Î«öLabel©ÎForm¤¤CaptionÄÝ©Ê©wªº§Ö³tÁä¡^¡A¿é¤JµJÂI·|¶]¨ì¨ÌTab¦¸§Ç©Ò¥X²{ªº±±¨î¶µ¡C¦]¦¹¥i§Q¥Î¦¹¤@¯S©Ê¨ÓÅýLabel¤ÎFrame±±¨î¶µ´£¨Ñ¤@§Ö³tÁä¨ì¥t¤@Ó±±¨î¶µ
' Åý¨Ï¥ÎªÌ¯à«öAlt+N§Ö³tÁä¨Ó²¾°ÊText1±±¨î¶µªº¿é¤JµJÂI¡C Label1.Caption = "&Name" Text1.TabIndex = Label1.TabIndex + 1
MousePointer¤ÎMouseIconÄÝ©Ê
¡@
³o¤GÓÄݩʼvÅT·Æ¹«´å¼Ð¦b±±¨î¶µ¤W²¾°Êªº§Îª¬¡AWindows´£¨Ñ«D±`¦³¼u©Êªº·Æ¹«´å¼ÐºÞ²z¡A¨C¤@Óªí³æ©Î±±¨î³£¥i¥H¦³¤£¦Pªº´å¼Ð¡A±z¥i¥H¨Ï¥Î¥þ°ìªºScreenª«¥ó¨Ó³]©wÀ³¥Îµ{¦¡½d³ò¤ºªº·Æ¹«´å¼Ð¡AÁöµM¦p¦¹¡A¦ý·|¼vÅT¹ê»Ú·Æ¹«³W«hªº±N¤£³Q¤¹³\¡G
¦p±ý¨Ï¥ÎªÌ²¾°Ê·Æ¹«®É¥X²{¨Fº|´å¼Ð¡A¥i°Ñ¦Ò¥H¤Uµ{¦¡½X¡G
'ªø½gªº±`¼Æ Screen.MousePointer = vbHourglass ... ' ¦b³oùسB²z±zªº¤u§@ ... ' °O±o§ï¦^Àx¦s¹w³]ªº´å¼Ð Screen.MousePointer = vbDefault
½Ð¬Ý¥t¥~¤@Ó¨Ò¤l¡G
' ·í·Æ¹«¦bPicturee1¤W®ÉÅã¥Ü¤Q¦r«¬´å¼Ð ' ·í·Æ¹«¦b¤÷ªí³æ¤W¨ä¥L±±¨î®ÉÅã¥Ü¨Fº|´å¼Ð Picture1.MousePointer = vbCrosshair MousePointer = vbHourglass
MouseIconÄݩʬO¥Î¥H´£¨Ñ¨Ï¥ÎªÌ¦Ûq·Æ¹«¡C¦b³oÓ¨Ò¤l¤¤¡A»Ý³]©wMousePointerȬ°99-vbCustomµM«á¦A«ü©w¤@ӹϥܵ¹MouseIconÄÝ©Ê¡C
'Åã¥Ü¬õ¦âªº°±¤î²Å¸¹·Æ¹«´å¼Ð¡C¹ê»Ú¤Wªº¸ô®|¦³¥i¯à·|¦]Visual Basic ¦w¸Ëªº¥D¥Ø¿ý¤£¦P¦Ó¤£¤@¼Ë¡C MousePointer = vbCustom MouseIcon = LoadPicture("d:\vb6\graphics\icons\computer\msgbox01.ico")
¦b°õ¦æ®É¥i¥H¤Å»Ý¥HLoadPicture«ü¥O¨Ó¸ü¤J¦Ûq·Æ¹«¡AÁ|¨Ò¨Ó»¡¡A¥i¥H¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤±N¨ä«ü¬£¨ìMouseIconÄݩʤ¤¡A½Ð°Ñ¬Ý¹Ï2-3¡A·í»Ý¨Ï¥Î®É¦A³]©wMousePointerȬ°99-vbCustom§Y¥i¨Ï¥Î¡C¦p±ý¹ï¦P¤@±±¨î¶µ¥i¿ï¾Ü¦hºØ´å¼Ð¡A¤S¤£·Q¼W¥[ÃB¥~ªºÀɮסA«h¥u»Ý¦bÁôÂêºImage±±¨î¶µ¤¤¦h¸ü¤JICOÀɮסA´N¥i¥H¦b°õ¦æ®É¤©¥H¤Á´«¡C
¡@
¹Ï2-3. Visual Basic 6´£¨Ñ³\¦h²{¦¨ªº¦Ûq·Æ¹«´å¼Ð¡B¹Ï¥Ü¤ÎÂI°}¹Ï¦b\GRAPHICS¤l¥À¿ý¤U¡C |
TagÄÝ©Ê
¡@
©Ò¦³ªº±±¨î¶µ½µL¨Ò¥~¦a³£¦³TagÄÝ©Ê¡A¬Æ¦Ü¬OActiveX±±¨î¶µ¡]¥]¬A¥ô¦ó¥L®a¼t°Óªº±±¨î¶µ¡^³£¦³¡C§Ú¤§©Ò¥H³o»òªÖ©w¬O¦]¬°³o¬OVisual Basic¥»¨©Ò´£¨ÑªºÄÝ©Ê¡A¦Ó¤£¬O¥Ñ±±¨î¶µ´£¨Ñªº¡C Tag¨Ã«DVisual Basic¹ï±±¨î¶µ©Ò´£¨Ñªº°ß¤@ÄÝ©Ê¡G¹³Index¡BVisible¡BTabStop¡BTabIndex¡BToolTipText¡BHelpContextID¤ÎWhatsThisHelpIDÄݩʳ£ÄݦP¤@Ãþ¡C³o¨ÇÄݩʳ£³Q·í§@¬O©µ¦ùªºÄÝ©Ê¡C½Ðª`·N¤@¨Ç©µÄݩʻݦb¬Y¨Ç±ø¥ó¤U¤~¦³¡A¨Ò¦pTabStop´N¥u¦b±±¨î¯u¥¿¦¬¨ìfocus¤~·|¥X²{¡A¦ÓTagÄݩʫܯS§O¡A¥Ã»·³£·|¦³¡A±z¤]¥i¦bµ{¦¡½X¤¤°Ñ·Ó¨ì¥L¦Ó¤£¥Î¾á¤ß·|°õ¦æ®É¥X²{¥ô¦ó¿ù»~¡C
TagÄݩʹïVisual Basic¨S¦³¯S§Oªº·N¸q¡G¨ä¥u¬OnÀx¦s¨ì±±¨î¶µªºÈªº¦¬¯Ç¾¹¡C¨Ò¦p¡G±z¥i¥Î¥L¨ÓÀx¦s±±¨î¶µªºªì©lÈ¡A¦p¦¹·í¨Ï¥ÎªÌ»Ýn¨ú®øÅܧó´N¥i¥H»´¦Ó©öÁ|¦a¦^´_¨ìì¨ÓªºÈ¡C
¨ä¥LÄÝ©Ê
¡@
ValueÄݩʬO³\¦h©T¦³ªº±±¨î¶µ«D±`´¶¹MªºÄÝ©Ê¡A¹³¦bCheckBox¡B OptionButton¡BCommandButton¤Î±²¶b±±¨î¶µ¬Æ¦Ü¬O³\¦h¥~³¡ªºActiveX±±¨î¶µ¤¤³£¦³¡C¦¹¤@Äݩʪº·N²[¦b¤£¦Pªº±±¨î¶µ´N·|¤£¦P¡A¦ý¥L̤@©w³£¬O¼ÆÈ©Î¥¬ªLÄÝ©Ê¡C
IndexÄݩʬO«Ø¥ß±±¨î¶µ°}¦CªºÃöÁä¡A Visual Basicºë±Kªº¯S©Ê¯àÀ°±z«Ø¥ß¦hºØ¥Î³~ªºµ{¦¡¡] ²Ä¤T³¹ ±N·|¶i¤@¨B¤¶²Ð±±¨î¶µ°}¦C¡^¡C¦p¤£»Ý«Ø¥ß±±¨î¶µ°}¦C¡A¥un¦b³]p¶¥¬qªºÄݩʵøµ¡¤¤±N¦¹¤@ÄÝ©Ê«O«ùªÅ¥Õ§Y¥i¡C¦¹¤@Äݩʦb°õ¦æ¶¥¬q¹ïÄݩ󱱨°}¦Cªº±±¨î¶µ¦Ó¨¥¬O°ßŪªº¡C¥t¥~¡A¦pªG°Ñ·Ó¨ì¤@«DÄݱ±¨î¶µ°}¦Cªº±±¨î¶µ¤§IndexÄÝ©Ê¡A Visual Basic´N·|²£¥Í¿ù»~¡C
¤j³¡¥÷©T¦³ªº±±¨î³£¤ä´©AppearanceÄÝ©Ê¡A¤]¥u¯à¦b³]p¶¥¬q«ü©wÈ¡A¦b°õ¦æ¶¥¬q´NÅܦ¨°ßŪªº¤F¡CVisual Basic·|¹w³]«Ø¥ß3-D¥~Æ[ªº±±¨î¶µ¡A°£«Dקï¤F¦¹¤@ÄÝ©ÊȬ°0-Flat¡A¹ïµ{¦¡±z¥i¯à·|¬°¤F»P¨ä¥Lµ{¦¡¬Ý°_¨Ó¤@P¦Ó¥hקï¥L¡A¦ý¹ï·sªºÀ³¥Îµ{¦¡¡A±z¤j¥i¤£¥²ºÞ¥L¡A¥un±NAppearanceÄݩʳ]¦¨¹w³]È¡]1-3D¡^§Y¥i¡C
Visual Basic¥i¥H¦Û°Ê¶Kªþ¤@Ó±±¨î¶µ¨ì¨ä¤÷µøµ¡ªº©Pªu¡A¥un³]©w¥LªºAlignÄÝ©ÊȬ°non-Null ¡C¥u¦³¤GÓ©T¦³ªº±±¨î¶µ¦³¦¹¤@ÄÝ©Ê¡G PictureBox¤ÎData±±¨î¶µ¡A¥t¥~¡A ¦h¼Æ¥~³¡ªºActiveX controls¤]¥i¥H¡C¦¹¤@ÄÝ©Ê¥i¯àªºÈ¦³¡G 0-None¡B1-Align Top¡B2-Align Bottom¡B3-Align Left¡B¤Î4-Align Right¡C
¤ä´©BorderStyleÄݩʪº±±¨î¶µ¦³¡G TextBox¡BLabel¡BFrame¡BPictureBox¡BImage¤ÎOLE±±¨î¶µ¡C³]©w¦¹ÄݩʪºÈ¬°0-None¥iÀ£ÁY±±¨î¾¹ªºÃä®Ø¦¨1-Fixed Single¡Cªí³æ¤]¤ä´©¦¹¤@ÄÝ©Ê¡A¦ý¨ä¤¹³\¦UºØ¤£¦Pªº³]©w¡]¥»³¹«á³¡±N¦A§@¤¶²Ð¡^¡C
¦b¤j³¡¥÷WindowsÀ³¥Îµ{¦¡¤¤²¾°Ê·Æ¹«¨ì¤@±±¨î¶µ©Î¹Ï¥Ü¨Ã°±¯d¤@¤U¡A³q±`´N·|¥X²{ToolTipªº¶À¦âµøµ¡¡C¡]¹Ï2-4¬OToolTipÅã¥Ü¥Xªº¦³¥Î´£¥Ü¡^¡C ¨ì¤FVisual Basic 4¡Aµ{¦¡¶}µo¤Hû¥²»Ý«Ø¥ß¯S§Oªº±`¼Æ©Î¶R¨ä¥L®aªº¤u¨ã¨Ó¼W¥[³oµ{¦¡ªº³oÓ¾÷¯à¡C¦Ó¦bVisual Basic 5¤Î6¡A«h¶È»Ýn«ü©wµ¹±±¨î¶µ¤¤ªºToolTipTextÄݩʤ@²Õ¦r¦ê§Y¥i¡C¥i±¤ªº¬O¡Aªí³æª«¥ó¨Ã¤£¤ä´©¦¹¤@ÄÝ©Ê¡C½Ðª`·NToolTipªº¦ì¸m¤Î¤j¤p¬O¤£¨ü±z±±¨îªº¡A¥u¯à¦b¨t²ÎȪº½d³ò¤º×§ï«e´º¤ÎI´ºÃC¦â¡]¶}±ÒControl Panelµøµ¡¡AÂù«öDisplayÄݩʹï¸Ü®Ø©Î¹Ï¥ÜµM«á²¾°Ê¨ìDisplayÄݩʹï¸Ü®Ø¤¤ªºAppearance¡A§Y¥iקïToolTipsªº¦r«¬¤ÎI´ºÃC¦â¡^¡C
¡@
¹Ï2-4 ToolTip½Ð±z¿é¤J©m¦W¡C |
DragMode¤ÎDragIconÄÝ©Ê¡]¤ÎDrag¤èªk¡^¬O¥Î¨Ó©ì¦²ªí³æ¤Wªº±±¨î¶µ¡A¤£¹L¥L̤w³QOLExxxx¤èªk¤ÎÄÝ©Ê©Ò´À¥N¡C¦³ªºÄÝ©ÊÁöµM¤´¬Û®e¡A¤£¹L¬°¨Ïµ{¦¡»P¬Û²Å©óWindows 95ªº¼Ð·Ç½Ð¤Å¦A¨Ï¥Î¡COLE Drag¤ÎDropÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó±N¦b ²Ä¤E³¹ ¤¤ªº¡q¨Ï¥Î©ì¦²¡rªº³¡¥÷¦A¸Ôz¡C
¥i¨Ï¥ÎLinkMode¡BLinkTopic¡BLinkItem¤ÎLinkTimeoutÄÝ©Ê¡]¥H¤ÎLinkPoke¡B LinkExecute¡BLinkRequest¤ÎLinkSend¤èªk¡^¨ÓÅX¨Ï¤@±±¨î¶µ©Îªí³æ³z¹LDDE (Dynamic Data Exchange)¨ó©w»P¨ä¥L±±¨î¶µ¤Îªí³æ¡]¬Æ¦Ü¦b¤£¦PªºÀ³¥Îµ{¦¡¤¤¡^·¾³q¡C¦bOLE¤ÎCOM°Ý¥@«e¡A DDE¬O¤GÓWindowsµ{¦¡¤¬³q³Ì¦nªº¤è¦¡¡C¦Ó®É¦Ü¤µ¤é¡A«h¤£À³¦A¨Ï¥Î¦¹§Þ³N¡A¦]¬°³o¨ÇÄݩʶȦbª©ªºµ{¦¡¤¤¥i¤©¥HºûÅ@¡C©Ò¥H¥»®Ñ±N¤£°Q½×DDEªº³¡¥÷¡C
¤@¯ëªº¤èªk
¡@
¦p¦P³\¦hª«¥ó¦@³qªºÄݩʤ@¼Ë¡A¤]¦³«Ü¦h¦@³qªº¤èªk¡C±µ¤U¨Ó±N¤@¤@À˵ø³o¨Ç¤èªk¡C
Move¤èªk
¡@
¤ä´©Left¡BTop¡BWidth¤ÎHeightÄݩʪº±±¨î¶µ´N¥i¤ä´©Move¤èªk¡C¦]¦¹¥i¥H³z¹L³æ¤@¨BÆJ§Y¥i¦P®É§ïÅܳo¥|Ó¤¤¥ô´XÓ©Î¥þ³¡ªºÄÝ©Ê¡A¤U±ªº¨Ò¤l´N§ïÅܤFLeft¡BTop¤ÎWidthÄÝ©Ê¡G
' Âù«öªí³æªº¼e«×±N¨ä²¾°Ê¨ì¿Ã¹õªº¥ª¤W¨¤ ' »yªk¡GMove, Left, Top, Width, Height. Form1.Move 0, 0, Form1.Width * 2
½Ðª`·N°£¤F²Ä¤@Ó¥H¥~ªº°Ñ¼Æ³£¬O¥i¦Û¿ïªº¡A¤£¹L¦b«ü¥O¤¤¶¡«o¤£¯à±N¨ä¥ô¦ó¤@¶µ¬Ù²¤¡CÁ|¨Ò¨Ó»¡¡A¦pªG¬Ù¥hWidth°Ñ¼Æ´N¤£¯à²¤¹LHeight°Ñ¼Æ¡A½Ðª`·Nµ§ªÌ´¿¦bÓ§OÄݩʤ¤¯S§O´£¨ìHeightÄݩʦbComboBox±±¨î¶µ¤¤¬O°ßŪªº¡C
¤p¯µ³Z
Move¤èªk³q±`¥u·|«ü¬£¨ì³æ¤@ÄÝ©Ê¡Aì¦]¬O¡G³o¼Ë§@¤ñ«ü¬£¨ì¥|ÓÄÝ©Ên¯à¼W¥[¤G¦Ü¤T¿ªº³t«×¡A¥t¥~¡A¦pªG»Ýקïªí³æ¤¤Width¤ÎHeightªºÄݩʮɡA¥ô¤@Äݩʪº«ü¬£³£·|IJµo§OªºResize¨Æ¥ó¡A¦Ó¨Ïµ{¦¡½Xªº®Ä¯à¤j´T´î§C¡C
Refresh¤èªk
¡@
Refresh¤èªk¥i«Ã¸±±¨î¶µ¡C¤@¯ë¨Ó»¡¬O¤£·|©I¥s³o¤@¤èªk¡A¦]¬°·í±±¨î¶µÅܧó®É¡]³q±`¬O¦bµL¨Ï¥ÎªÌµ{¦¡½X°õ¦æ¥BVisual Basic³B©ó¶¢¸mªºª¬ºA¤U¡^¡AVisual Basic·|¦Û°Ê§ó·s¨ä¥~Æ[¡A¤£¹LYn¦bקﱱ¨î¶µÄÝ©Ê¥B§Æ±æ¨Ï¥ÎªÌ¤¶±¤]¥ß§Y§ó·sªº¸Ü¡A¤´¥i¥l³êRefresh¤èªk¡G
For n = 1000 To 1 Step -1 Label1.Caption = CStr(i) Label1.Refresh ' ¥ß§Y§ó·sLabel Next
ª`·N
¤]¥i¨Ï¥ÎDoEvents«ü¥O¨Ó§ó·sªí³æ¡A¦]¬°³oÓ«ü¥O¥iÄÀ©ñ±±¨î¶µ¨ìVisual Basic¤¤¡A Visual Basicªí³æ¤ÞÀº´N¥i¥H§ó·s¨Ï¥ÎªÌ¤¶±¡C¤£¹Lnª`·NDoEvents¤]·|³y¦¨°õ¦æÃB¥~ªºµ{§Ç¡]¨Ò¦p¡G¥L·|Àˬd¬O§_¦³¥ô¦ó«ö¶s¤w³QÂI¿ï¡AY¬O¡A·|¥ý°õ¦æClickµ{§Ç¡^¡C¦]¦¹¡A³o¤GӤ覡¨ä¹ê¤£ºÉ¬Û¦P¡A¤@¯ë»¡¨Ó¡A¥u¹ï¤w³Qק諸±±¨î¶µ¨Ï¥ÎRefresh¤èªk·|¤ñ°õ¦æDoEvents«ü¥O®ÄªG§ó¦n¡C¦AªÌ¡A³o¼Ë¤]¥iÁקK¦A«×¶i¤J·|¤Þ°_¿ù»~¡A¨Ò¦p¡G·í¨Ï¥ÎªÌ¦b¤§«eªºClickµ{§ÇÁÙ¨S§¹¦¨¦A¦¸ÂI¿ï¦P¤@«ö¶s¡CYn·sªí³æ¤W©Ò¦³±±¨î¶µ¦Ó¤£§Æ±æ¥Î¤áºÝ¯à»Pµ{¦¡¤¬°Ê®É¡A½Ð¦b¤÷ªí³æ¤¤°õ¦æRefresh¤èªk§Y¥i¡C
SetFocus¤èªk
¡@
SetFocus¤èªk¥i¦b¯S©wªº±±¨î¶µ²¾°Ê¿é¤Jfocus¡C¦b³]p¶¥¬q¡A±ýקï¥H³]©wªí³æ¤W±±¨î¶µªºTabIndexÄݩʤ§¹w³]©w¦ìÂIªº¶¶§Ç®É¡]½Ð°Ñ¦Ò
²Ä¤@³¹ ¡^¡A´N»Ýn©I¥s³oÓ¤èªk¡C³o®É±±¨î¶µªºTabIndexÄÝ©ÊÈÀ³¬°0¡A·íªí³æ¸ü¤J§Y¥i±µ¨üfocus¡CSetFocus¤èªk¦³Ó¼ç¦bªº°ÝÃD´N¬O¡G¦pªG±±¨î¶µ¥Ø«e¬OµL§@¥Î©Î¬O¬Ý¤£¨ìªº¡A¨º»ò³oÓ¤èªk´NµL®Ä¥B·|¦b°õ¦æ®É²£¥Í¿ù»~¡A¦]¦¹¡A¦bForm_Load¨Æ¥ó¡]·íÁÙµLªk¬Ý¨£©Ò¦³±±¨î¶µ®É¡^nÁקK¨Ï¥Î¦¹¤èªk¡A¥BÀ³¥H¤U¦C¤GºØ¤è¦¡³B²z¡G²Ä¤@Ó¬O½T»{±±¨î¶µ¤w·Ç³Æ¦n±µ¨üfocus¡A²Ä¤GÓ¬O¦bOn Error°£z¦¡¤¤¥ý¹w¨¾¿ù»~ªºµo¥Í¡A²Ä¤@Ӥ覡½Ð°Ñ¦Ò¥H¤Uµ{¦¡½X¡G
'²¾°Êfocus¨ìText1. If Text1.Visible And Text1.Enabled Then Text1.SetFocus End If
¥H¤U¬°²Ä¤GӤ覡ªºµ{¦¡½X¡A§Q¥ÎOn Error³¯z¦¡¡G
'²¾°Êfocus¨ìText1 On Error Resume Next Text1.SetFocus
¤p¯µ³Z
SetFocus¤èªk³q±`¦bForm_Load¨Æ¥óµ{§Ç¤¤¥Î¥H³]©w·íªí³æ²Ä¤@¦¸¥X²{®É¡A¨º¤@Ó±±¨î¶µ¥i±µ¨üfocus¡C
Private Sub Form_Load() Show ' ¨Ïªí³æ¦¨¬°¥i¨£ªº Text1.SetFocus End Sub
¥H¤U´£¨Ñ¥t¤@ӸѨM¤è®×¡G
Private Sub Form_Load() Text1.TabIndex = 0 End Sub
½Ðª`·N¦pªGText1µLªk±µ¨ü¿é¤J¾nÂI¡]¨Ò¦p¡G¨äTabStopÄݩʳ]©w¬°False¡^¡AVisual Basic·|¦Û°Ê¨Ì©w¦ìÂI¦¸§Ç²¾°Ê¾nÂI¨ì¤U¤@Ó±±¨î¶µ¡A¦Ó¤£²£¥Í¥ô¦ó¿ù»~¡C²Ä¤GӤ覡ªº¯ÊÂI¦b©ó¨ä·|¼vÅTªí³æ¤W©Ò¦³¨ä¥L±±¨î¶µªºTab¦¸§Ç¡C
Zorder¤èªk
¡@
Zorder¤èªk¼vÅT±±¨î¶µ»P¨ä¥¦«Å|ªº±±¨î¶µ½Ö¥i¬Ý±o¨£¡C¦pn±N¤@±±¨î¶µ»\¦b¥t¤@Ó±±¨î¶µ¤W±¡A¥un°õ¦æ³oÓ¤èªk¦Ó¤£»Ý¥ô¦ó°Ñ¼Æ¡A¤S©ÎªÌ¤]¥i¥H³]1¬°°Ñ¼Æ²¾¨ì«á±¡G
' ²¾°Êªí³æ¤W¤@±±¨î¶µ¨ì¥t¤@±±¨î¶µ«á± Text1.ZOrder 1 Text1.ZOrder ' ·h¨ì«e±
½Ðª`·N¤]¥i©ó³]p¶¥¬q¨Ï¥Î ®æ¦¡ ²M³æ Order ¤l¥Ø¿ýªº«ü¥O¨Ó³]©w±±¨î¶µªº¬Û¹ïz-order¡A¤]¥i¥H«ö Ctrl+J Áä±N¿ï¨úªº±±¨î¶µ±a¨ì«e±¡A©Î«ö Ctrl+K Áä·h¨ì«á±¡C
Zorder¤èªk¹ê»Úªº°Ê§@·|¦]±±¨î¶µ¬°¼Ð·Çªº©ÎµLµøµ¡ªº¦Ó¤£¦P¡C¨Æ¹ê¤W¡AµLµøµ¡ªº±±¨î¶µ®Ú¥»¤£·|¥X²{¦b¼Ð·Ç±±¶µªº«e±¡A´«¥y¸Ü»¡¡A³o¤GºØ±±¨î¶µ¤À§O¦bz-order¤GÓ¤£¦Pªº¼h¦¸¤¤¡A¼Ð·Ç±±¨î¶µªº¼h¦¸·|¦bµLµøµ¡±±¨î¶µªº¼h¦¸¤§«e¡A³oªí¥ÜZorder¤èªk¥u¦b¨ä©ÒÄݪº¼h¦¸¤¤¥i¥H§ïÅܱ±¨î¶µ¬Û¹ïªºz-order ¡CÁ|¨Ò¨Ó»¡¡A¤@Ó¯à±N¤@Label¡]µLµøµ¡ªº¡^±±¨î¶µ©ñ¦bTextBox¡]¼Ð·Çªº¡^¤§«e¡A¤£¹L¡AY¼Ð·Çªº±±¨î¶µ¥i§@¥Î¦¨¦¬¯Ç¾¹±±¨î¶µ¡]¨Ò¡GPictureBox©ÎFrame¡^¡AÁ|¨Ò¨Ó»¡¡A¦pªG±NµLµøµ¡ªº±±¨î¶µ¥]§t¦b¦¬¯Ç¾¹±±¨î¶µ¤¤¡A´N¥i¥HÅã¥Ü¦b¼Ð·Çªº±±¨î¶µ¤§«e¡A½Ð°Ñ¦Ò¹Ï2-5¡C
Zorder¤èªk¤]¾A¥Î©óªí³æ¡A¥i¥H¦b¬Û¦PªºVisual BasicÀ³¥Îµ{¦¡¤¤±N¤@ªí³æ°e¨ì¥t¤@ªí³æªº¤U±©Î«e±¡A¤£¹LY¬°±±¨îªí³æ»P¨ä¥LÀ³¥Îµ{¦¡©ÒÄݵøµ¡ªº¬Û¹ï¦ì¸m¡A«h¤£n¥Î³o¤@Ó¤èªk¡C
¡@
¹Ï2-5 ±±¨î¶µªº¬Û¹ïz-order¡C |
³q¥Îªº¨Æ¥ó
¡@
°£¤F³q¥ÎªºÄݩʤΤèªk¡AVisual Basic 6ªí³æ¤Î±±¨î¶µ¤]¦³³q¥Îªº¨Æ¥ó¡A¥H¤U¥»¸`±N³v¤@¤¶²Ð¡C
Click¤ÎDblClick¨Æ¥ó
¡@
Click¨Æ¥ó¬O·í¨Ï¥ÎªÌ¦b±±¨î¶µ¤W«ö·Æ¹«¥ªÁä®É·|µo¥Í¡ADblClick¨Æ¥ó¬O¦b±±¨î¶µ¤WÂù«ö·Æ¹«¥ªÁäµo¥Í¡C¤£¹L³o»ò²³æªº¤Àªk¨Ã«Dµ´¹ïªº¡AClick¦b¨ä¥L±¡ªp¤U¤]¥i¯àµo¥Í¡CÁ|¨Ò¨Ó»¡¡G CheckBox©ÎOptionButton±±¨î¶µªºValueÄݩʤ£½×¤°»ò®ÉÔ¸g¥Ñµ{¦¡½XÅܧó¡AVisual Basic´N·|IJµoClick¨Æ¥ó¡A¦pªG¨Ï¥ÎªÌÂI¿ï¥¦¤]¬O¤@¼Ë·|IJµo¸Ó¨Æ¥ó¡C³oӰʧ@¥i¥HÅý§Ú̥άۦPªº¤è¦¡³B²z¤GÓ¤£¦Pªº®×¨Ò¡C¨C·íListBox¤ÎComboBox±±¨î¶µªºListIndexÄÝ©ÊÅܧï¡A¤]·|IJµoClick¨Æ¥ó¡C
Click»PDblClick¨Æ¥ó¤£·|¶Ç°Ñ¼Æ¨ìµ{¦¡¤¤¡A¦]¦¹¤£¯à¨Ì¿à³o¤GӨƥó¨Ó§iª¾¥Ø«e·Æ¹«ªº¦ì¸m¡Anª¾¹D·Æ¹«ªº¦ì¸mn¥t¥~¥ÎMouseDown¨Æ¥ó¡Aµy«á·|¹ï¦¹¤@¨Æ¥ó¥t§@¤¶²Ð¡C¥t¥~½Ðª`·N·íÂù«ö±±¨î¶µ®É¡A¨ä·|¦P®É±µ¨üClick¤ÎDblClick¨Æ¥ó¡A¦]¦¹«ÜÃø¥h§PÂ_¬O³æÂI¿ï¤G¦¸ÁÙ¬OÂù«ö¤@¦¸¡A¦]¬°·íVisual Basic©I¥sClick¨Æ¥óµ{§Ç«á¬O§_·|¦A©I¥sDblClickµ{§Ç¡A©Ò¥H½ÐÁקK¹ï¬Û¦Pªº±±¨î¶µ«ü¬£¤£¦Pªº¨ç¼Æ¨ìclick¤Îdouble-click°Ê§@¤¤¡A¥H§K¥O¨Ï¥ÎªÌ²V²c¡C
¤p¯µ³Z
¦]¬°¹ï¦P¤@±±¨î¶µ¤£¯àÓ§O«ü¬£¨ìclick¤Îdouble-click¤GӰʧ@¡A¥H¤U¬O³oÓ²©öªº¤èªk¯à§ä¥X¨Ï¥ÎªÌ¯u¥¿°µ¤F¤°»ò°Ê§@¡G
¡@
' ¼Ò²Õ¼h¯ÅÅÜ¼Æ Dim isClick As Boolean Private Sub Form_Click() Dim t As Single isClick = True ' ¹w¯d¥b¬íÄÁµ¥«Ý²Ä¤G¦¸ÂI¿ï t = Timer Do DoEvents ' ¦pªGDblClickµ{§Ç¨ú®ø¦¹¨Æ¥ó¡A«h¸õ¥X If Not isClick Then Exit Sub ' The next test accounts for clicks just before midnight. Loop Until Timer > t + .5 Or Timer < t ' ±N§Aªº³æÀ»(single-click)µ{§Ç¼g¦b³o¸Ì ... End Sub Private Sub Form_DblClick() ' ¨ú®ø¥ô¦óªº¹w³ÆClick isClick = False ' ±N§AªºÂùÀ»(double-click)µ{§Ç¼g¦b³o¸Ì ... End Sub
Change¨Æ¥ó
¡@
Change¨Æ¥ó¬OVisual Basic©Ò´£¨Ñ³Ì²³æªº¨Æ¥ó¡G¥un±±¨î¶µªº¤º®e§ïÅÜ¡AVisual Basic´N·|IJµoChange¨Æ¥ó¡C¤£¹L«Ü¥i±¤¡A³o»ò²³æªº³]p¨Ã¤£¬Û²Å©óVisual Basicªº¬[ºc¡C¦p¦P§Ú¦b¤W¤@¸`¤¤©Ò´£¨ìªº¡A·íÂI¿ïCheckBox¤ÎOptionButton±±¨î¶µ®É¡A§YIJµoClick¨Æ¥ó¡]¦Ó¤£¬OChange¨Æ¥ó¡^¡A¤£¹L¡A³o¤£¬Û²Åªº¦a¤èËÁÙ¤£ºâÄY«¡C
·í¨Ï¥ÎªÌ¦bTextBox¤ÎComboBox±±¨î¶µ¥i½s¿èªº°Ï°ì¥´¤@¨ÇªF¦è¡A´N·|²£¥ÍChange¨Æ¥ó¡]¤£¹L½Ðª`·N¡G·íComboBox²£¥ÍªºClick¨Æ¥ó¬O¦b¨Ï¥ÎªÌ¿ï¨ú¦Û²M³æ¤¤¿ï¨ú¶µ¥Ø®É¡A¦Ó¤£¬O¦b®Ø®Ø¤¤¥´¤F¦r¡^¡C±²¶b±±¨î¶µ«h¬O·í¨Ï¥ÎªÌÂI¿ïÁY©ñ©Î²¾°Ê±²¶b®É·|²£¥ÍChange¨Æ¥ó¡CPictureBox¡BDriveListBox¤ÎDirListBoxµ¥±±¨î¶µ¤]³£¤ä´©Change¨Æ¥ó¡C
·í±±¨î¶µªº¤º®e³z¹Lµ{¦¡½X§ïÅܮɤ]·|IJµoChange¨Æ¥ó¡A¦¹¤@¦æ¬°³q±`·|P¨Ïµ{¦¡Åܱo¦³¨ÇµL®Ä²v¡CÁ|¨Ò¨Ó»¡¡G¤j³¡¥÷ªºµ{¦¡³]p®v·|¦bªí³æªºLoad¨Æ¥ó¤¤ªì©l¤Æ©Ò¦³TextBoxªºTextÄÝ©Ê¡A¦]¦¹Ä²µo¤Ó¦hªºChange¨Æ¥ó¦ÓÅý¸ü¤Jµ{§ÇÅܺC¡C
GotFocus¤ÎLostFocus¨Æ¥ó
¡@
³o¤GӨƥóÆ[©À¤W«Ü²³æ¡G·í±±¨î¶µ±µ¨ü¿é¤J¾nÂI®É¡AGotFocus´N·|IJµo¡A¦Ó·í¿é¤J¾nÂI²¾¶}¨ì¥t¤@±±¨î¶µ®É¡ALostFocus´N·|IJµo¡C¥E¬Ý¤§¤U¡A³o¤GӨƥó¦ü¥G¬O¥i²z·Q¦a°õ¦æ¤@²Õ½T»{¾÷¨î¡]´N¬O«ü·í¿é¤JȨ䣥¿½T¦Ó¨Ï¥ÎªÌ¤S²¾¨ì¨ä¥L±±¨î¶µ®É¡AÀˬdÄæ¦ì¤Î³qª¾¨Ï¥ÎªÌªºµ{¦¡½X¤ùÂ_¡^¡C¦³®É¡A³o¤G¨Æ¥óªºµ²ªG¨ü³\¦h¦]¯Àªº¼vÅT¡G¥]¬AMsgBox¤ÎDoEvents³¯z¦¡ªºªí²{¡CÁÙ¦nVisual Basic 6¤w¤¶²Ð¤F·sªºValidate¨Æ¥ó¯àº}«G¦a¸Ñ¨M½T»{Äæ¦ìªº°ÝÃD¡]½Ð¥t¨£²Ä¤T³¹¤¤ªº
CausesValidationÄݩʤÎValidate¨Æ¥ó ¡^³Ì«á¡A½Ðª`·Nªí³æ¦P®É¤ä´©GotFocus¤ÎLostFocus¨Æ¥ó¡A¤£¹L³o¤G¨Æ¥ó³£¥u¦bªí³æ¤£§t¥ô¦ó±µ¨ü¿é¤J¾nÂIªº±±¨î¶µ®Éµo¥Í¡A¤£½×¬O¦]¬°©Ò¦³±±¨î¶µ¬O¬Ý¤£¨ìªº©Î¬O¨äTabStopÄݩʳ]¬°Fales¡C
KeyPress¡BKeyDown¤ÎKeyUp¨Æ¥ó
¡@
³o¤TӨƥó¬O¨C·í¥Î¤áºÝ¦b¦³¿é¤J¾nÂIªº±±¨î¶µ¤W«öÁä®É´N·|IJµo¡C¨äµo¥Íªº¶¶§Ç¦p¤U¡GKeyDown¡]¨Ï¥ÎªÌ«ö¤U«öÁä¡^¡BKeyPress¡]Visual Basic±N«öÁäĶ¦¨ANSI¼Æ¦r½X¡^¤ÎKeyUp ¡]¨Ï¥ÎªÌ©ñ¶}«öÁä¡^¡C¥u¦³»P±±¨î¬ÛÃöªº«öÁä¡]¨Ò¦p¡G Ctrl+x ¡B BackSpace ¡B Enter ¤Î Esc ¡^¤Î¥i¦L¥Xªº¦r¤¸¦bKeyPress¨Æ¥ó¤¤¦³§@¥Î¡C¦Ü©ó¨ä¥Lªº«öÁä¡]¥]¬A¤è¦VÁä¡B¥\¯àÁä¤Î Alt+x µ¥µ¥¡^«h¤£·|IJµo³oӨƥó¦ý·|²£¥ÍKeyDown¤ÎKeyUp¨Æ¥ó¡C
KeyPress¨Æ¥ó¬O³o¤TӨƥ󤤳̲³æªº¨Æ¥ó¤F¡A¥L¥i¶Ç¥X¨Ï¥ÎªÌ«ö¤Uªº«öÁäANSI½X¡A¦]¦¹³q±`»Ý¥ÎCh$() ¨ç¼Æ±N¨äÂà´«¬°¦r¦ê¡G
Private Text1_KeyPress(KeyAscii As Integer) MsgBox "User pressed " & Chr$(KeyAscii) End Sub
¦pקïKeyAsciiªº°Ñ¼Æ¡A«h·|¼vÅTµ{¦¡¸ÑĶ«öÁ䪺¤è¦¡¡A¤]¥i¥H³]©w°Ñ¼ÆȬ°0¨Ó¡u¦Y±¼¡v¤@Ó«öÁä¡A½Ð¬Ý¬Ý¥H¤Uµ{¦¡½X¡G
Private Sub Text1_KeyPress(KeyAscii As Integer) ' ±N©Ò¦³«öÁäÂà´«¦¨¤j¼g¨Ã¥h°£ªÅ¥Õ. KeyAscii = Asc(UCase$(Chr$(KeyAscii) If KeyAscii = Asc(" ") Then KeyAscii = 0 End Sub
KeyDown¤ÎKeyUp¨Æ¥ó¥i±µ¨ü¤GӰѼƪº³]©w¡GKeyCode¤ÎShif¡CKeyCode¬O«ö¤U«öÁ䪺µ{¦¡½X¡A¦ÓShift«h¬O¦^³øCtrl¡BShift¤ÎAlt«öÁ䪬ºAªº¤@¾ã¼ÆÈ¡A¦]¬°³oÓȬO¦ì¤¸µ{¦¡½X¡A©Ò¥H¥²»Ý¨Ï¥ÎAND¹Bºâ¤l¨ÓÂ^¨ú¬ÛÃö¸ê°T¡G
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If Shift And vbShiftMask Then ' Shift key pressed End If If Shift And vbCtrlMask Then ' Ctrl key pressed End If If Shift And vbAltMask Then ' Alt key pressed End If ' ... End Sub
KeyCode°Ñ¼Æ¥i»¡©ú¨º¤@Ó«öÁä³Q«ö¤U¡A¦]¦¹»PKeyPress¨Æ¥ó©Ò±µ¨üªºKeyAscii°Ñ¼Æ¬O¤£¦Pªº¡C³q±`¥i¥H¥Î²Å¸¹±`¼Æ¨Ó´ú¸Õ¦¹¤@È¡A½Ð°Ñ¬Ý¥H¤Uµ{¦¡½X¡G
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) ' Y¨Ï¥ÎªÌ«ö[Ctrl]+[F2]¡A«h´À´«±±¨î¶µªº¤º®e¬°¥Ø«eªº¤é´Á If KeyCode = vbKeyF2 And Shift = vbCtrlMask Then Text1.Text = Date$ End If End Sub
¬Û¹ï©óKeyPress¨Æ¥ó¡A¦pªG«ü¬£¤£¦PªºÈ¨ìKeyCode°Ñ¼Æ¤¤¡A«hµLªkÅܧóµ{¦¡ªº¦æ¬°¡C
n¯S§Oª`·NKeyPress¡BKeyDown¤ÎKeyUp¨Æ¥ó¦b°»¿ùªº¶¥¬q¥i¯à·|¥X²{¯S§Oªº°ÝÃD¡C¨Æ¹ê¤W¡A¦pªG¦bKeyDown¨Æ¥óµ{§Ç¤¤©ñ¸m¤@Ó¤¤Â_ÂI¡A«h¥Ø¼Ð±±¨î¶µ±N¥Ã»·¤£·|±µ¨ü«öÁ䪺³qª¾¡A¨Ã¥BKeyPress¤ÎKeyUp ¨Æ¥ó¤]¤£·|IJµo¡C¬Û¦Pªº¡A¦pªG·íVisual Basic¦b°õ¦æKeyPress¨Æ¥óµ{§Ç®É¶i¤J¤¤Â_¼Ò¦¡¡A¥Ø¼Ð±±¨î¶µ«h¥i¥H±µ¨ü«öÁä¡A¤£¹LKeyUp¨Æ¥ó¤´¤£·|IJµo¡C
¤p¯µ³Z
·íµLªk½s¿èKeyCode°Ñ¼Æ¤]¤£¯à¥HקïȨӼvÅTµ{¦¡®É¡A³oùØ´£¨Ñ¤@Ó¤p§Þ¥©¡G¤j³¡¥÷ªº®ÉÔ¡A¥i¥H¦bTextBox±±¨î¶µ¤¤ÄÀ©ñ¦h¾lªº«öÁä¡G
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyDelete Then '¨Ï±±¨î¶µ¬°°ßŪ¡A«h¥iÄÀ©ñ«öÁä Text1.Locked = True End If End Sub Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) ' Àx¦s¥¿±`ªº¹Bºâ¤l Text1.Locked = False End Sub
KeyDown¡BKeyPress¤ÎKeyUp¨Æ¥ó¶È·í«öÁä«ö¦b¦³¿é¤J¾nÂIªº±±¨î¶µ¤W¤~¥i³Q±µ¨ü¡A³oÓ±¡§Î¨Ï±o«Ø¥ßªí³æ¼h¯Åªº«öÁäÃѧO½X¡]§Y¡Gµ{¦¡½XºÊµø¦bªí³æ¤W¥ô¦ó±±¨î¶µ«ö¤Uªº«öÁ䤧µ{¦¡¤ùÂ_¡^®ÉÅã±o§xÃø¡AÁ|¨Ò¨Ó»¡¡A°²³]²{»ÝÅý¨Ï¥ÎªÌ¥i«ö[F7]¨Ó²M°£¥Ø«eÄæ¦ì¡A¤S¤£·Q¦bKeyDown¨Æ¥óµ{§Ç¤¤¹ï¨C¤@Óªí³æ¤W¨C¤@Ó±±¨î¶µ¼g¦P¼Ë¤ùÂ_ªºµ{¦¡½X¡A«h¥un³]©wªí³æªºKeyPreviewÄݩʬ°True¡]¨Ò¡G¦b³]p¶¥¬q©Î°õ¦æ¶¥¬q³£¥i¥H¦bForm_Loadµ{§Ç¤¤°µ¡^¡AµM«á¼g¤U¥H¤Uªºµ{¦¡½X¡G
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF7 Then ' An error handler is necessary because we can't be sure ' that the active control actually supports the Text ' property. On Error Resume Next ActiveControl.Text = "" End If End Sub
Yªí³æªºKeyPreviewÄݩʤw³]¬°True¡A«hªí³æª«¥ó±µ¨ü©Ò¦³¦b¨ä³Q°e¨ì¥Ø«e¦³¿é¤J¾nÂIªº±±¨î¶µ¤§«e»PÁä½L¬ÛÃöªº¨Æ¥ó¡A¦p±ý¦b¦³¿é¤J¾nÂIªº±±¨î¶µ¤W°Ê§@¡A«h¥i¨Ï¥Î¤W¨Òµ{¦¡½X¤ùÂ_¤¤ªí³æªºActiveControlÄÝ©Ê¡C
MouseDown¡BMouseUp¤ÎMouseMove¨Æ¥ó
¡@
³o¤TӨƥó¬O¦b·Æ¹«¦b±±¨î¶µ¤W³QÂI¿ï¡BÄÀ©ñ©Î²¾°Ê®Éµo¥Í¡A¤TªÌ³£±µ¨ü¬Û¦Pªº°Ñ¼Æ²Õ¡G·Æ¹««ö¶sªºª¬ºA¡BShift/Ctrl/Alt«öÁ䪺ª¬ºA¥H¤Î·Æ¹«´å¼Ðªºx¤Îy®y¼Ð¡A¦¹®y¼Ð¬O¬Û¹ï©ó±±¨î¶µ©Îªí³æªº¥ª¤W¨¤¦Ó©w¡C¹Ï2-6¬OÅã¥Ü¦bLabel±±¨î¶µ¤Wªº·Æ¹«ª¬ºA¤Î¦ì¸m¡A¥H¤Î«Ø¥ß¦b§Y®Éµøµ¡¤¤ªº¤é»x¤§µ{¦¡½X½d¨Ò¡C¤]¥i©ó¹Ï2-6¤¤¬Ý¨ìµ{¦¡½X°õ¦æªºµ²ªG¡C
¡@
¹Ï2-6 ¥HMouseDown¡BMouseMove¥H¤ÎMouseUp¨Æ¥ó¨ÓºÊ¬Ý·Æ¹«ª¬ºA¡C½Ðª`·N·í´å¼Ð¶]¥Xªí³æªº½d³ò®ÉȬ°t¡C |
Private Sub Form_MouseDown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) ShowMouseState Button, Shift, X, Y End Sub Private Sub Form_MouseMove(Button As Integer, _ Shift As Integer, X As Single, Y As Single) ShowMouseState Button, Shift, X, Y End Sub Private Sub Form_MouseUp(Button As Integer, _ Shift As Integer, X As Single, Y As Single) ShowMouseState Button, Shift, X, Y End Sub Private Sub ShowMouseState (Button As Integer, _ Shift As Integer, X As Single, Y As Single) Dim descr As String descr = Space$(20) If Button And vbLeftButton Then Mid$(descr, 1, 1) = "L" If Button And vbRightButton Then Mid$(descr, 3, 1) = "R" If Button And vbMiddleButton Then Mid$(descr, 2, 1) = "M" If Shift And vbShiftMask Then Mid$(descr, 5, 5) = "Shift" If Shift And vbCtrlMask Then Mid$(descr, 11, 4) = "Ctrl" If Shift And vbAltMask Then Mid$(descr, 16, 3) = "Alt" descr = "(" & X & ", " & Y & ") " & descr Label1.Caption = descr Debug.Print descr End Sub
¦b¼g·Æ¹«¨Æ¥óªºµ{¦¡½X®É¡A¥²»Ýª`·N¦b¥Î³o¨Ç¨Æ¥ó®É¤@¨Ç°õ¦æªº²Ó¸`¤Î©ö¥Çªº¿ù»~¡A½Ð°O±o¥H¤U´XÂI¡G
±µ¤U¨Ó¬Ý¬ÝMouseDown¡BMouseUp¤ÎMouseMove¨Æ¥ó»PClick¤ÎDblClick¨Æ¥óªºÃö«Y¡G
ªí³æª«¥ó
¡@
¦b¸Ô²Ó¤¶²Ð¤j³¡¥÷Visual Basicª«¥ó³q¥ÎªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó«á¡A²{¦b¨ÓÓ§O¬Ý¬Ý¨ä¯SÂI¡C³Ì«n¬Ý±o¨ìªºª«¥óº±Àªí³æª«¥ó¤F¡A¦]¬°¦pªG¨S¦³¤÷ªí³æ«hµLªkÅã¥Ü¥ô¦ó±±¨î¶µ¡A¤Ï¤§¡A¥u¾aªí³æ¦Ó¨S¦³¥ô¦ó±±¨î¶µ¤]¥i¥H¼g¤@¨Ç¦n¥ÎªºÀ³¥Îµ{¦¡¡C¦b¥»¸`¤¤±N¥H¤@¨Ç½d¨Ò¨Ó¤¶²Ðªí³æ©_¯Sªº©Ê½è¡C
¦b³]p¶¥¬q¡A¥i±q ±M®× ²M³æ¤¤ªº ·s¼Wªí³æ «ü¥O©Î¦b¼Ð·Ç¤u¨ã¦C¤¤ÂI¿ï¦P¤@¹Ï¥Ü¨Ó«Ø¥ß·sªºªí³æ¡C¥i¥H¥Î¹º½u¨Ó«Ø¥ßªí³æ¤]¥i¥H§Q¥Î³\¦hVisual Basic6©Ò´£¨Ñªºªí³æ¼ÒªO¡CYµLªk¬Ý¨ì¹Ï2-7©ÒÅã¥Üªº¹ï¸Ü¤è¶ô¡A½Ð±q ¤u¨ã ²M³æ¤¤¥l³ê ¿ï¶µ «ü¥O¡A¹Ï¿ï Àô¹Ò ¶ÅÒ¡A¦A¿ï¥kÃä³Ì¤W±ªº®Ö¨ú¤è¶ô§Y¥i¡C
¨C·í»Ýn«Ø¥ß·sªí³æ®É¡A¤j¥i¾¨¶q¨Ï¥Îªí³æ¼ÒªO¡Cªí³æ¼ÒªO¨Ã¤£¤@©w¬O·|¦³«Ü¦h±±¨î¶µªº½ÆÂøªí³æ¡A§Y¨Ï¥u¬O¦³¤@²Õ¤w¤p¤ß³]©wÄݩʪºªÅ¥Õªí³æ¤]¯à¸`¬Ù¤@¨ÇÄ_¶Qªº®É¶¡¡C¨Ò¦p¡GVisual Basic©Ò´£¨Ñªº¹ï¸Üªí³æ¼ÒªO¡C¦p±ý²£¥Í¦Ûqªºªí³æ¼ÒªO¡A«h¥u»Ý«Ø¥ß¤@Óªí³æ¡A¦A¥[¤W¤@¨Ç¥²»Ýªº±±¨î¶µ¡AµM«á±N¨äÀx¦s©ó\Template\Forms¥Ø¿ý¤U¡]Visual Basic¼ÒªOªº§¹¾ã¸ô®|¥i©ó ¿ï¶µ ¹ï¸Ü®Ø¤¤ªº Àô¹Ò ¶ÅÒ¤¤Åª¨ú¨Ãקï¡C
¡@
¹Ï2-7 Visual Basic 6©Ò´£¨Ñªºªí³æ¼ÒªO |
ªí³æªº°ò¥»ÄÝ©Ê
¡@
«Ø¥ß¤F©Ò»Ý¨D¤j¤pªºªí³æ«á¡A±z¥i·|·Q¦A³]©w¤@¨Ç«nªºÄÝ©Ê¡CBorderStyle¥iºâ¬O¼vÅTªí³æ¦æ¬°³Ì¤jªºÄݩʤF¡A¨ä¹w³]Ȭ°2-¤j¤p¥i½Õ¾ã¡A§Y¯à«Ø¥ß¥i½Õ¾ã¤j¤pªºµøµ¡¡C¦p±ý«Ø¥ßªº¬O¤£¥i½Õ¾ã¤j¤pªºªí³æ¡A«h¨äÈÀ³³]¬°1-³æ½u©T©w©Î3-Âù½u©T©w¹ï¸Ü¤è¶ô¡G¤GºØ³]©wªº¤£¦P¦b©ó«áªÌ¤£·|¥X²{ ÁY¨ì³Ì¤p ©Î ©ñ¨ì³Ì¤j ªº«ö¶s¡C¦p±ý«Ø¥ß¯B°Êªº¡B ¹³¤u¨ã½cªºªí³æ¡A«hȻݳ]¬°4-³æ½u©T©w¤u¨ãµøµ¡©Î5-¥i½Õ¾ã¤u¨ãµøµ¡¡C²z½×¤W¡A¤]¥i¥H¨Ï¥Î0-¨S¦³®Ø½u¨Ó²¾°£¥ô¦ó¤@ºØ®Ø½u¤Î¼ÐÃD¡A¤£¹LÂA¤Ö·|¥Î¨ì¨S¦³®Ø½uªºªí³æ¡C
±µ¤U¨Ó¸Ó¨M©w¦b¼ÐÃD¦Cn¥X²{ªºªF¦è¤F¡C°£¤F¦bªí³æªºCaptionÄݩʤ¤«ü¬£¾A·íªº¦r¦ê¥~¡A¤]À³¨M©w¬O§_nÅýªí³æ¤ä´©¨t²Î²M³æ¤Î Ãö³¬ «ö¶s¡]ControlBoxÄÝ©Ê¡A¹w³]Ȭ°True¡^¡B ÁY¨ì³Ì¤p ¤Î ©ñ¨ì³Ì¤j «ö¶s¡]¤À§O¬OMinButton¤ÎMaxButtonÄÝ©Ê¡^¡C¬°³o¨ÇÄÝ©Ê¿ï¾Ü¥¿½TªºÈ«D±`«n¡A¦]¬°¦b°õ¦æ¶¥¬q¬OµLªk¥Hµ{¦¡½X¦A¨Óק諸¡C¦p§Æ±æªí³æ¤@¶}©l´N¬O©ñ¨ì³Ì¤jªºª¬ºA¡A«h¥i³]WindowStateÄÝ©ÊȬ°2-³Ì¤j¤Æ¡C
¤p¯µ³Z
¦p±ý«Ø¥ßµL¼ÐÃD¡B¤j¤p¥i½Õ¾ãªºµøµ¡¡A«h»Ý³]©wControlBox¡BMinButton¤Î MaxButtonÄÝ©ÊȬ°False¡A¨Ã³]©wCaptionÄݩʬ°ªÅ¦r¦ê¡C¦pªG¦b°õ¦æ¶¥¬q«ü¬£Caption¬°«DªÅ¦r¦ê¡AVisual Basic´N·|«Ø¥ßªí³æªº¼ÐÃD¦b¨ä¤W¡AµL¼ÐÃD¦Cªºªí³æµLªk¹³¨ä¥L«¬ºAªºµøµ¡¤@¼Ë¥i¥H·Æ¹«²¾°Ê¡C
Visual Basic 5·s¼W¤F¤TÓ«nªºªí³æÄÝ©Ê¡A¥B¦bVisual Basic 6¤´Ä~Äò«O¯d¡C¥i¥H³]©wStartupPositionÄÝ©ÊȬ°2-¿Ã¹õ¤¤¥¡¡A¨ÓÅýªí³æ¦b¿Ã¹õ¤¤¥¡¥X²{¡C¤]¥i¥H³]©wMoveableÄÝ©ÊȬ°False¡A¨Ïµøµ¡µLªk³Q²¾°Ê¡C¥u¦³¦b³]p¶¥¬q¥i³]©w¥H¤W¤GÓÄÝ©Ê¡C²Ä¤TÓ«h¬OShowInTaskbar¡F¦p³]©wÄÝ©ÊȬ°False¡A«hªí³æ¤£·|¥X²{¦bµøµ¡¨t²Îªº¤u¨ã¦C¤W,¡CµL¼ÐÃDªºªí³æ¦b¤u¨ã¦C¤W«h¬Ý°_¨Ó¹³¤@Ó¡uªÅªº¡vªí³æ¤@¼Ë¡A¦]¦¹¹ï³oºØªí³æ³Ì¦n³]©wShowInTaskbarÄÝ©ÊȬ°True¡C
ªí³æªº®Ä¯à½Õ¾ã
¡@
¦³¨Çªí³æªºÄÝ©Ê«D±`©úÅã¦a¼vÅT¨ä®Ä¯à¡C²Ä¤@¦Wº±ÀAutoRedrawÄÝ©Ê¡A¨ä¥i©R¥Oªí³æ¬O§_n¥Ñ¤@©T©wªºÂI°}¹Ï¨Ó³Æ¥÷¡A¦p¦¹¤@¨Ó¡A·í¨ä³Q¨ä¥Lªí³æÂл\«á¤´¯àÅãÅS¥X¨Ó¡A¦]¬°Visual Basic¯à§Ö³t¦a¥H¤º³¡ªºÂI°}¹Ï¨Ó««Ø¨ä¤º®e¡CAutoRedrawªº¹w³]Ȭ°False¡G³]©w¬°True¥i¥[³t§ó·s¹Bºâ¤l¤£¹L¤]·|³y¦¨¤j¶q°O¾ÐÅé¦w±Æ¨ì³oÓ©T©wªºÂI°}¹Ï¡C¬°Åý±z¤F¸Ñ¹ê°È¤W¨ä·N¸q¡G¹ï1024*768¿Ã¹õ¸ÑªR«×¤Î256¦âªº¨t²Î¦Ó¨¥¡A¤@Ó¦b¥i½Õ¾ã¤j¤pªí³æ¤W©T©wªºÂI°}¹Ï·|¦û¥h768KB¡F¦Ó¦b800*600¹³¯À¡A¥þ±m¨t²Î¤W«h¦û1406KB¡CY¦³§ó¦hªºªí³æ¦b¦P®É¶¡°õ¦æ¡A§ó¯àÃÒ©ú¤£¥i±NAutoRedrawÄÝ©Êȳ]¬°True¡A¦Ü¤Ö¤£n¬O©Ò¦³ªºªí³æ³£³]¬°True¡CAutoRedrawÁÙ·|¥Î§OºØ¤è¦¡¼vÅT®Ä¯à¡G¨C¦¸°õ¦æø¹Ï¤èªk¡]¥]¬A¦L¥X¤å¦r¤Îµe¹Ï§Î¡^¡AVisual Basic¦bÁôÂ꺩T©wÂI°}¹Ï¤W«Ø¥ß¿é¥X¡AµM«á½Æ»s¾ãÓÂI°}¹Ï¨ìªí³æ¤W¬Ý±o¨ìªº°Ï°ì¡C¤£¥Î»¡¡A³o¤@©w¤ñ¦bªí³æ¤Wª½±µ«Ø¥ß¿é¥XnºC±o¦h¤F¡C
¤p¯µ³Z
¦pªGAutoRedraw³]¬°True¡AVisual Basic±N¦bªí³æ¤W«Ø¥ß³Ì¤j¥i¯àªº©T©wÂI°}¹Ï¡A¤]´N¬O«ü¾ãÓ¥i½Õ¤j¤pµøµ¡ªº¿Ã¹õ¡C¦]¦¹¡AY¬O«Ø¥ß¸û¤pªºªí³æ¨Ã³]©w¨äBorderStyleÄݩʬ°1-³æ½u©T©w©Î3-Âù½u©T©w¹ï¸Ü¤è¶ô¡A´N¥i¥H¨î°O¾ÐÅé¦]©T©wÂI°}¹Ï©Ò¤Þ°_ªº®ø¯Ó¡C
ClipControlsÄݩʤ]·|¼vÅT®Ä¯à¡A¦pªG°õ¦æ³\¦hø¹Ï¤èªk¡]¨Ò¦p¡GLine¡BCircle¡BPoint¤ÎPrint¡^¡A«hÀ³³]©wÄÝ©ÊȬ°False¡A¦]¬°©Ò¦³¥Î¨ìªºÃ¸¹Ï¤èªk³£·|°õ¦æ¤G¦¸¡C·í³]©wÄÝ©ÊȬ°False¡AVisual Basic´N¤£»Ýn«Ø¥ß°Å¨ú°Ï¡AµM¦Ó¡A¦pªG©Ò¥ÎªºÃ¸¹Ï¤èªk»Pªí³æªº±±¨î¶µ«Å|¡A«h·|²£¥Í¦p¹Ï2-8¤¤«Ü®tªº®ÄªG¡A©Ò¥Hn¯S§Oª`·N¡C¡]»P¹Ï2-9¤ñ¸û¡A¨ä©ÒÅã¥ÜªºÁö¬O¦P¤@À³¥Îµ{¦¡¡A¦ý¬OClipControlsȳ]¬°True¬O§ó¾A¦Xªº¡^¡C¦p¤£°õ¦æø¹Ï¤èªk¡A¦]¬°¨ä¤£·|ÅýÀ³¥Îµ{¦¡ÅܺC¡A«h¥i±N¨äȳ]¬°True¡]¹w³]È¡^¡C
¡@
¹Ï2-8 ·íø¹Ï¤èªk»P¦s¦bªº±±¨î¶µ«Å|¡A³]©wClipControlsªº±_ª¬®ÄªG¡C |
¡@
¹Ï2-9 ¥H§ó¾A¦XªºClipControlsÄÝ©ÊÈ°õ¦æ¹Ï2-8¤¤ªºÀ³¥Îµ{¦¡ |
HasDCÄݩʬOVisual Basic 6ªº·s¦¨û¡A¹w³]Ȭ°True¡A¥i¤ÞµoVisual Basic«Ø¥ßªí³æ±`¸mªºdevice Context¡Adevice Context®e±N©Mªí³æ¸ü¤J°O¾ÐÅé«á¦@¦s¤`¡]device Context¬OWindows¥Î¥H¦bµøµ¡ªí±Ã¸¹Ï©Ò¨Ï¥Îªºµ²ºc¡^oY³]©w³oÓȬ°False¡A«hVisual Basic¶È·|¦b½T¹ê»Ýn®É¬°ªí³æ«Ø¥ßdevice context¨Ã©ó¤£¦A¨Ï¥Î®É§Y¤©®ø·À¡C¦¹ºØ³]©w´N¨t²Î¸ê·½¦Ó¨¥·|´î¤ÖÀ³¥Îµ{¦¡ªº»Ý¨Dn¥ó¡A¦]¦Ó¥i¼W¶i®Ä¯à¡C¦b¥t¤@¤è±¡A¨C·íVisual Basic«Ø¥ß¤Î®ø·À¼È¦sªºdevice context¤]·|¼W¥[¤@¨ÇÃB¥~ªºt¾á¡A³oºØ±¡§Î¦bVisual Basic©óµ{¦¡½X¤¤Ä²µo¨Æ¥ó®É·|µo¥Í¡C
ª`·N
±z¦b³]©wHasDCÄݩʬ°False®É¤]¤´¯à½µL°ÝÃD¦a°õ¦æ¥ô¦ó¤w¦s¦bªºVisual BasicÀ³¥Îµ{¦¡¡C¦pªG²{¦bn¥Î¶i¶¥Ã¸¹Ï§Þ¥©¡A¶V¹LVisual Basicª½±µ¼g¤Jªí³æªºdevice context¡A«h¤£¥i¥H±Nªí³æªºhDCÄݩʦs¨ì¼Ò²Õ©Î¼s°ìÅܼƤ¤¡A¦]¬°¦p¦¹¤@¨ÓVisual Basic·|©ó¤G¨Æ¥ó¶¡®ø·À¨Ã««Øªí³æªºdevice context¡A©Ò¥HÀ³¸Ó¦b¨C¤@¨Æ¥óµ{§Ç¤@¶}©l´N¥ý¸ß°ÝhDCÄݩʪºÈ¡C
ªí³æªº¥Í©R¶g´Á
¡@
n¤F¸Ñªí³æª«¹ê»Ú¤W¬O¦p¦ó¹B§@¡A³Ì¦nªº³~®|´N¬O¨Ó¬Ý¬Ý¨Æ¥óµo¥Íªº¶¶§Ç¡C½Ð°Ñ¦Ò¥H¤U¹Ï¸Ñ»¡©ú¡A§Ú¤]·|¨Ì§ÇÁ¿¸Ñ¦UӨƥó¡C
¡@
Initialize¨Æ¥ó
¡@
¥ô¦óªí³æ¥Í©R©P´Áªº²Ä¤@Өƥó´N¬Oªì©l¤Æ¨Æ¥ó¡C¤@¦ý°Ñ·Ó¨ìµ{¦¡½X¤¤ªí®æªº¦W¦r¡A§Y¨Ï¬O¦bVisual Basic¦b¨äªí±«Ø¥ß¹êÅ骺µøµ¡¤Î±±¨î¶µ¤§«e¡A´N·|IJµo¦¹¨Æ¥ó¡A³q±`¦b¨Æ¥ó¤¤·|¥Îµ{¦¡½X¨Ó¥¿½Tªì©l¤Æªí³æªºÅܼơG
Public CustomerName As String Public NewCustomer As Boolean Private Sub Form_Initialize() CustomerName = "" ' ³o¤@¦æ¨Ã¤£¯uªº»Ýn NewCustomer = True ' ³o¤@¦æ¬°¥²n End Sub
·íªí³æªì©l¤Æ¤§«á¡A¨ä©Ò¦³ªº¼Ò²Õ¯ÅÅܼơ]¨Ò¦p¦b¥H¤Wµ{¦¡¤¤ªºCustomerName¤ÎNewCustomer¡^È·|³Q«ü¬£¦¨¥L̪º¹w³]È¡C©Ò¥H·í¨äȬ°0©ÎªÅ¦r¦ê®É¡A¨Ã¤£«Ü»Ýn¥h«ü¬£µ¹ÅܼƤ@ÓÈ¡C¨Ò¦p¦b¥H¤Wªºµ{¦¡½X¤¤¡A«hµL»Ý«ü¬£CustomerNameÅܼƤ@ÓÈ¡A¤£¹L±z¥i¯à·|§Æ±æ«O¯d¨äÈ¥H«K¦³¸û¦nªº¥i«H«×¡C
Load¨Æ¥ó
¡@
¦bªì©l¤Æ¤§«á©Òµo¥Íªº¨Æ¥ó·|¦]µ{¦¡½X¦p¦ó°Ñ·Ó¨ìªí³æ¦Ó¦³¤£¦P¡A¦pªG¥u°Ñ·Ó¨ì¨ä¬Y¤@¤½¥ÎÅܼơ]©Î§ó¥¿½T¦a»¡¬OPublicÄÝ©Ê¡^¡A½Ð°Ñ¦Ò¤U±³o¦æµ{¦¡½X¡G
frmCustomer.CustomerName = "John Smith"
¦pµL¨ä¥L¨Æ¥óµo¥Í«h°õ¦æ¬yµ{·|¦^¨ì©I¥s³Bµ{¦¡(caller)¡C²{¦bµ{¦¡½X³]©w¤FCustomerNameÅܼơþÄݩʤ@Ó·sÈ¡A¦]¬°¦b¦¹®É¡A Visual Basic¤w«Ø¥ß¤FfrmCustomerª«¥ó¤@Ó·sªº°õ¦æÓÅé¡C¦b¥t¤@¤è±¡A¦pªGµ{¦¡½X¦bªí³æ¥»¨°Ñ·Ó¨ì¦Û¤vªºÄݩʩα±¨î¶µ¡A«hVisual BasicµLªk§¹¦¨¹B§@¡Aª½¨ì¨ä«Ø¥ß¯u¥¿ªºµøµ¡¤Î¨ä¤l±±¨î¶µ¡C·í¦¹¨BÆJ¤w§¹¦¨¡A«KIJµoLoad¨Æ¥ó¡G
Private Sub Form_Load() ' ªì©l¤Æ¤l±±¨î¶µ txtName.Text = CustomerName If NewCustomer Then chkNewCustomer.Value = vbChecked End Sub
¦b¦¹®Éªí³æ¤´µM¬Ý¤£¨ì¡A·N«ä´N¬O¦pªG¦b³oӨƥóµ{§Ç¤¤°õ¦æø¹Ï«ü¥O¡]¥]¬APrint«ü¥O¡A¦]¬°Print«ü¥O¦bVisual Basic¤¤³Q»{¬°¬Oø¹Ï«ü¥O¡^¤]¬Ý¤£¨ì¥ô¦óªF¦è¡C¦P¼Ëªº¡A·í¥i¦Û¥Ñקï¤j³¡¥÷±±¨î¶µÄݩʪº®ÉÔ¡A¤]À³ÁקK¥ô¦óµLªk©ó¬Ý¤£¨£ªº±±¨î¶µ¤W°õ¦æªº«ü¥O¡C¨Ò¦p¡A¤£¥h¥l³êSetFocus¤èªk¦b¯S®í±±¨î¶µ¨Ó²¾°Ê¾nÂI¡C
¸ü¤Jªí³æ¨Ã¤£¤@©wªí¥Üªí³æ´N·|Åܦ¨¬Ý±o¨£ªº¡C¥u¦³¦b¥l´«ªí³æªºShow¤èªk©Î¸Óªí³æ¬OÀ³¥Îµ{¦¡ªº±Ò°Êªí³æ¡A¤~·|¦¨¬°¬Ý±o¨£ªºªí³æ¡C¦p¤U¡A¥i¥H¨M©wn¸ü¤Jªí³æÁÙ¬OÁôÂèì³]©w¨ä¬Y¨ÇÄݩʬ°¤î¡G
'Load¤èªk¬O¥i¦Û¥Ñ¿ï¾Üªº¡G 'Visual Basic¦b°Ñ·Ó¨ìªí³æ©Î¨ä±±¨î¶µ®É·|¸ü¤Jªí³æ Load frmCustomer ' ª½±µ«ü¬£±±¨î¶µÄÝ©ÊDirectly assign a control's property ' ¡]¤£«Øij³o»ò°µ¡A¤£¹L¤´¨Ñ°Ñ¦Ò¡^ frmCustomer.txtNotes.Text = gloCustomerNotes frmCustomer.Show
¦p¤W½d¨Ò¤¤ªºµ{¦¡½Xª½±µ±qªí³æ¥~³¡°Ñ·Óªí³æªº±±¨î¶µ¡A¨ä¹ê¬O«Ü®t«lªºµ{¦¡§Þ¥©¡C¦b
²Ä¤E³¹ ·|¥t¥~¤¶²Ð¦p¦ó¥¿½T¦aªì©l¤Æ±±¨î¶µÄÝ©Ê¡C
Resize¨Æ¥ó
¡@
¤@·íªí³æÅܦ¨¬Ý±o¨£®É¡AVisual Basic§Y·|IJµoResize¨Æ¥ó¡C³q·í³oӨƥó¬O¥Î¨Ó«·s¦w¸mªí³æ¤Wªº±±¨î¶µ¡A¦p¦¹¤@¨Ó¨ä¥i°t¦XªÅ¶¡¦Ó¦³¸û¨Îªºª©±°t¸m¡C¨Ò¦ptxtCustomer±±¨î¶µ©µªø¥kÃä¬É¤Î¦h½uªºtxtNotes±±¨î¶µ©µªø¥kÃä¬É¤Î¤UÃä¬É¡G
Private Sub Form_Resize() txtCustomer.Width = ScaleWidth _ txtCustomer.Left txtNotes.Width = ScaleWidth _ txtNotes.Left txtNotes.Height = ScaleHeight _ txtNotes.Top End Sub
·í¨Ï¥ÎªÌ¤â°Ê½Õ¾ãªí³æ¤j¤p¤Î·íµ{¦¡´£¥Üªí³æªº¤j¤p®É¡A¤]·|IJµoResize¨Æ¥ó ¡C
Activate¨Æ¥ó
¡@
ºò±µ¦b²Ä¤@¦¸ªºResize¨Æ¥ó¤§«áªº´N¬OActivate¨Æ¥ó¤F¡CµL½×¦ó®Éªí³æ¦b¥Ø«eªºÀ³¥Îµ{¦¡¤¤Åܦ¨§@¥Î¤¤ªí³æ¡A¤]·|IJµo³oӨƥó¡A¤£¹L·íªí³æ¥ó¥¢¥h¾nÂI¡]focus¡^«á§Y¨Ï¤S¦A¨ú±o¤]¤£·|IJµo³oӨƥó¡A¦]¬°¨Ï¥ÎªÌ¤w¸õ¨ì¥t¤@ÓÀ³¥Îµ{¦¡¤¤¤F¡CActivate¨Æ¥ó¦b»Ýn§ó·sªí³æªº¤º®e¤§¸ê®Æ¤w¦b¨ä¥LÀ³¥Îµ{¦¡¤¤³Qקï¹L®É³Ì¦n¥Î¤F¡C·í¾nÂI¦^¨ì¥Ø«eªºªí³æ®É¡A§Y¦P®É§ó·s¨äÄæ¦ì¡G
Private Sub Form_Activate() ' §ó·sÅã¥Ü¼s°ìÅܼƪº¸ê°T txtTotalOrders.Text = gloTotalOrders ... End Sub
Paint¨Æ¥ó
¡@
¦bªí³æ¯à§¹¥þ§@¥Î«e¥i¯à·|IJµoªº¥t¤@¨Æ¥ó¥i¯à¬OPaint¨Æ¥ó¡C³oӨƥó¦b³]©wªí³æªºAutoRedrawÄݩʬ°True®É«h¤£·|IJµo¡C¦bPaint¨Æ¥óµ{§Ç¤¤¡A±N¹w´Á·|¨Ï¥Îø¹Ï¤èªk¡]¨Ò¦p¡GPrint¡BLine¡BCicle¡BPoint¡BClsµ¥µ¥¡^¨Ó«µeªí³æªº¤º®e¡A¥H¤U¬Oµe¤@±m¦â¶ê¹vªº½d¨Ò¡G
Private Sub Form_Paint() Dim r As Single, initR As Single Dim x As Single, y As Single, qbc As Integer ' ¥H²M°£µe±¶}©l Cls ' ©Ò¦³¶êªº¶ê¤ß x = ScaleWidth / 2: y = ScaleHeight / 2 ' ì©l¥b®|·|¤ñ³o¤GÓȤp If x < y Then initR = x Else initR = y FillStyle = vbFSSolid ' Circles are filled. ' ¥Ñ¥~¦V¤ºµe¶ê For r = initR To 1 Step -(initR / 16) ' ¨C¤@Ó¶ê¨Ï¥Î¤£¦PªºÃC¦â FillColor = QBColor(qbc) qbc = qbc + 1 Circle (x, y), r Next ' ««Ø¤@¯ë¶ñº¡«¬ºA FillStyle = vbFSTransparent End Sub
Paint¨Æ¥óµ{§Ç¨C·íªí³æ»Ýn§ó·s®É´N·|°õ¦æ¡A¨Ò¦p¡G·í¨Ï¥ÎªÌÃö³¬©Î²¾°Ê¤@³¡¥÷©Î§¹¥þÂл\ªí³æµøµ¡ªº®ÉÔ¡C·í¨Ï¥ÎªÌ½Õ¾ãªí³æªº¤j¤p¡A©Î²¾¶}Åã¥Ü·s°Ï°ì®É¡A¤]·|IJµoPaint¨Æ¥ó¡C¤£¹L·í¨Ï¥ÎªÌÁY¤pªí³æ®É«h¤£·|µo¥Í¡C¬°¨Ï¥H¤W½d¨Ò§¹¾ã¡A¥i¯àÁÙ·|»Ýn¦bResize¨Æ¥ó¤¤¤â°Ê¨ÓIJµoPaint¨Æ¥ó¡A³o¼Ë¤@¨Ó¡A¦P¤ß¶ê´N·|¥Ã»·³£¦bªí³æªº¥¿¤¤¶¡¡G
Private Sub Form_Resize() Refresh End Sub
ª`·N
¤d¸U¤£¥i¥H¤â°Ê©I¥sForm_Paint¨Ó±j¢¨ÏPaint¨Æ¥óµ{§Çµo¥Í¡A¯u¥¿¥¿½T¦Ó³Ì¦³®Ä²vªº¤è¦¡À³¬O«µe¤@Óµøµ¡¨Ó°õ¦æ¨äRefresh¤èªk¡AµM«áÅýVisual Basic¨M©w³Ì¾A·íªº®É¾÷¨Ó°µ¡C¦AªÌ¡A¦pªGª½±µ¥H©I¥sForm_Paintµ{§Ç¨Ó¨ú¥NRefresh¤èªk¡A¦b¨ä¨Çª¬ªp¤Uµ²ªG·|Åܦ¨Paint¨Æ¥óµ{§Ç°õ¦æ¤G¦¸¡C
¦b²Ä¤@¦¸ªºPaint¨Æ¥ó¤§«á¡]©Î¬O·íAutoRedrawÄݩʬ°True®É¡Aºò¸ò¦bActive¨Æ¥ó¤§«á¡^¡Aªí³æ§Y·Ç³Æ¦n±µ¨ü¨Ï¥ÎªÌ¿é¤J¸ê®Æ¡C¦Ó¦pªí³æ¨Ã¤£¥]§t¥ô¦ó±±¨î¶µ©Î¨ä±±¨î¶µ¨S¦³¤@Ó¬O¥i±µ¨ü¿é¤J¾nÂIªº¸Ü¡Aªí³æ¥»¨·|±µ¨üGotFocus¨Æ¥ó¡C¨ä¹ê«Ü¤Ö»Ý¦bªí³æªºGotFocus¼gµ{¦¡½X¡A¦]¬°³q±`·|¥HActivate¨Æ¥ó¨Ó¥N´À¡C
Deactivate¨Æ¥ó
¡@
¦p¦P¤§«e´¿´£¨ìªº¡A·í¸õ¨ìÀ³¥Îµ{¦¡¤¤¥t¤@Óªí³æ®É¡A³oÓªí³æ§Y±µ¨üDeactivate¨Æ¥ó¦Ó¥t¤@ÓActivate¨Æ¥ó«h·|«O¯d¿é¤J¾nÂI¡C¦pªG¥l³êHide¤èªk¨Ó³]©wVisibleÄݩʬ°False¡A¦Ó¼È®ÉÁôÂêí³æ¡A¤]·|¦³¦P¼Ëªºµ²ªG¡C
QueryUnload¨Æ¥ó
¡@
·íªí³æ±N³Q²¾°£¡A«hªí³æª«¥ó·|±µ¨üQueryUnload¨Æ¥ó¡AÂÇ¥ÑÀËÅçUnloadMode°Ñ¼Æ¨Óª¾¹Dªí³æ¬°¤°»ò·|³Q²¾°£¡Cµ§ªÌ¤w«Ø¥ß¦bµ§ªÌªºÀ³¥Îµ{¦¡¤¤¥i¨Ñ§Q¥Îªºµ{¦¡½X¬[ºc¦p¤U¡G
Private Sub Form_QueryUnload(Cancel As Integer, _ UnloadMode As Integer) Select Case UnloadMode Case vbFormControlMenu ' = 0 ' ªí³æ±N³Q¨Ï¥ÎªÌÃö³¬ Case vbFormCode ' = 1 ' ªí³æ±N³Qµ{¦¡½XÃö³¬ Case vbAppWindows ' = 2 ' ¥Ø«eWindows sessionµ²§ô Case vbAppTaskManager ' = 3 ' Task ManagerÃö³¬À³¥Îµ{¦¡ Case vbFormMDIForm ' = 4 ' ¤÷MDIÃö³¬ªí³æ Case vbFormOwner ' = 5 ' ¾Ö¦³ªí³æªÌÃö³¬ End Select End Sub
¥i¥H³]©wCancel°Ñ¼Æ¬°True¨Ó©Úµ´²¾°£¡A½Ð¬Ý¥H¤Uµ{¦¡½X¡G
Private Sub Form_QueryUnload(Cancel As Integer, _ UnloadMode As Integer) ' ¤£Åý¨Ï¥ÎªÌÃö³¬ªí³æ Select Case UnloadMode Case vbFormControlMenu, vbAppTaskManager Cancel = True End Select End Sub
Unload¨Æ¥ó
¡@
Y¤£·Q¨ú®ø²¾°£¹B§@¡A Visual Basic³Ì«á·|²£¥ÍUnload¨Æ¥ó¡A¨Ã·|µ¹³Ì«á¤@¦¸¾÷·|¨Ó½T«Oªí³æ¤£³QÃö³¬¡C¤j³¡¥÷ªº±¡§Î¤U¡A¥i§Q¥Î¦¹¾÷·|¨Óĵ¥Ü¨Ï¥ÎªÌ»Ý¥hÀx¦s¸ê®Æ¡G
' ¼Ò²Õ¯ÅªºÅÜ¼Æ Dim Saved As Boolean Private Sub Form_Unload(Cancel As Integer) If Not Saved Then MsgBox "Please save data first!" Cancel = True End If End Sub
°£«D¨ú®øn¨D¡A§_«h·í°h¥XUnload¨Æ¥óµ{§Ç«á¡AVisual Basic·|®ø·À©Ò¦³±±¨î¶µ¨Ã²¾°£ªí³æ¡AÄÀ©ñ©Ò¦³©ó¸ü¤J¶¥¬q¤À°tªºWindows¸ê·½¡C¥l³êªí³æªº¤è¦¡¡A¤]¥i¯à¤]·|IJµoªí³æªºTerminate¨Æ¥ó¡A§Y©ñ¸m²M°£µ{¦¡½Xªº¦a¤è¡BÃö³¬ÀÉ®×µ¥µ¥¡C¦¹¨Æ¥óIJµo¡]©Î¤£µo¥Í¡^ªººØºØì¦]±N©ó²Ä¤E³¹¤¤¤¶²Ð¡C
ª`·N
·íIJµoTerminate¨Æ¥ó¡Aªí³æª«¥ó¨ä¹ê¤w¸g¤£¦b¡A©Ò¥HµL»Ý©óµ{¦¡½X¤¤°Ñ·Ó¨ì¥L©Î¨ä±±¨î¶µ¡C¦pªG¸I¥©³o»ò°µ¤F¡A¤]¤£·|²£¥Í¿ù»~¡C¦Ó¬OVisual Basic·|«Ø¥ß¥t¤@Ó·sªºªí³æª«¥ó°õ¦æÓÅé(instant)¡A¨Ã±NÀqÀqÁôÂæb°O¾ÐÅ餤¦Ó¤£·|®ø¯Ó¤j¶q¨t²Î¸ê·½¡C
±±¨î¶µªº¶°¦Xª«¥ó
¡@
ªí³æÅã¥Ü¤@ӫܯS§OªºÄÝ©Ê´N¬O±±¨î¶µªº¶°¦XÅé¡A¨ä¥]§t¤F©Ò¦³¥Ø«e³Q¸ü¤Jªºªí³æ¤§±±¨î¶µ¡C¦¹¶°¦Xª«¥ó¥i¨Ïªí³æ¼Ò²Õªºµ{¦¡½X§ó¦³®Ä²v¡A¥B¬O¤@¨Çµ{¦¡³]p¤£¥i©Î¯ÊªºÃöÁä§Þ¥©¡CÁ|Ó¨Ò¤l¨Ó¬Ý¡A¥un¥|¦æµ{¦¡½X§Y¥i²M°£ªí³æ¤W©Ò¦³TextBox¤ÎComboBox±±¨î¶µ¡A«Ü²³æ§a¡G
On Error Resume Next For i = 0 To Controls.Count - 1 Controls(i).Text = "" Next
¦b¦¹¿ù»~³B²z¬O¥²nªº¡A¦]¬°¥²»Ý»¡©ú¦bªí³æ¤W©Ò¦³ªº±±¨î¶µ¨Ã¤£¤ä´©TextÄÝ©Ê¡C¨Ò¦p¡A±±¨î¶µ¤l¶°¦X¡]Controls collection¡^¥ç¥]§t¤F©Ò¦³¦bªí³æ¤Wªº¥\¯àªí¶µ¥Ø¡A¦Ó¥\¯àªí¶µ¥Ø¨ÃµLTextÄÝ©Ê¡C©Ò¥H¡A·í«ÂФl¶°¦X®É´N¥²»Ý¤©¥H¸ÑÄÀ³o¨Ç±¡ªp¡C¥H¤U¬O¥t¤@Ӥ覡¡A¥Î³q¥ÎªºControlª«¥ó¤ÎFor Each...Next³¯±Ô¦¡¨Ó´`Àô¶°¦X¤¤ªº©Ò¦³±±¨î¶µ¡G
Dim ctrl As Control On Error Resume Next For Each ctrl In Controls ctrl.Text = "" Next
¤Wz¤GÓµ{¦¡¤ùÂ_¹ïªí³æ¤W¥ô¦ó±±¨î¶µ³£¥i¥H¨Ï¥Î¡A¦Ó¥B§Y¨Ï±N¨ä°Å¶K¨ì¨ä¥Lªí³æ¼Ò²Õ¤W¤]¯à§@¥Î¡C±±¨î¶µ¤l¶°¦XÀuÂI´N¬O¥i«Ø¥ß³oÃþìµLªk¥H¨ä¥L¤è¦¡¨Ó¼gªº³q¥Î°Æµ{¦¡¡C¥»®Ñ¦b¤§«á¤]·|¤¶²Ð³\¦h¨ä¥L±±¨î¶µ¤l¶°¦Xªºµ{¦¡³]p¡C
Screenª«¥ó
¡@
Visual Basicªí³æ¦s¦b©ó¹q¸£¿Ã¹õ¤W¡C§Y¨ÏÀ³¥Îµ{¦¡¶È·|¨Ï¥Î¨ì¿Ã¹õªº³¡¥÷°Ï°ì¡A¤´»Ýn¦n¦n¨Ó»{Ãѳo¤@ª«¥ó¡CVisual Basic¹ï¬Ý±o¨ìªº®à±´£¨Ñ¤F¬ÛÃöªº¥þ°ìªº¿Ã¹õª«¥ó¡C
ªí³æªºLeft¡BTop¡BWidth¤ÎHeightÄݩʬO¥HTWIPpºâ¡ATwip¬O¿Ã¹õ¤Î¦Lªí¾÷¸Ë¸m©Ò¨Ï¥Îªºpºâ³æ¦ì¡C¹ï¦Lªí¾÷¦Ó¨¥¡A¤@^¦T¬Û·í©ó1400ÓTwip¡F¦Ó¦b¿Ã¹õ¤W¡A«hn¨ÌºÊµø¾¹ªº¤j¤p¤Îµø°T¥d¥Ø«eªº¸ÑªR«×¦Ó©w¡C±z¥i±q¿Ã¹õª«¥óªºWidth¤ÎHeightÄݩʨӧä¥X¥Ø«e¿Ã¹õªº¤j¤p¡]¦h¤Ötwip¡^¡AµM«á¦A¨Ó¨Ï¥Î³o¨ÇÈ¡A¨Ò¦p¡G¥i¥H¥Î¥H¤Uµ{¦¡½X¨Ó²¾°Ê¥Ø«eªºªí³æ¨ì¿Ã¹õ¥k¤U¨¤¡G
Move Screen.Width - Width, Screen.Height - Height
ÁöµM¿Ã¹õª«¥óµLªk¶Ç¦^¨ä¥L³æ¦ìªºÈ¡A¤´¥i¥H»´¦Ó©öÁ|¦a¥H¿Ã¹õª«¥óªºTwipsPerPixelX»PTwipsPerPixelYÄݩʨÓÂà´«¨äȨ칳¯À¡G
' ¥H¹³¯Àp¶q¿Ã¹õªº¼e«×¤Î°ª«× scrWidth = Screen.Width / Screen.TwipsPerPixelX scrHeight = Screen.Height / Screen.TwipsPerPixelY 'ÁY¤p¥Ø«eªºªí³æ¡Gx¶bÁY¤p¢°¢¯Ó¹³¯À¡Ay¶bÁY¤p20Ó¹³¯À Move Left, Top, Width - 10 * Screen.TwipPerPixelX, _ Height - 20 * Screen.TwipsPerPixelY
¿Ã¹õª«¥ó¥i¥H¥ÎFont¤ÎFontCountÄݩʨӦCÁ|©Ò¦³¿Ã¹õ¥i¥Îªº¦r¡G
' ¦b¤U©Ô¦¡²M³æ¤¤¸ü¤J©Ò¦³¿Ã¹õ¦r§Îªº¦W¦r Dim i As Integer For i = 0 To Screen.FontCount - 1 lstFonts.AddItem Screen.Fonts(i) Next
¿Ã¹õª«¥ó¶È¦³¤GÓÄݩʬO¥i¼g¤Jªº¡GMousePointer¤ÎMouseIcon¡]¦b¤§«e¤w¤¶²Ð¹L¤F¡^¡A¥i¨Ï¥Î¥H¤U³¯±Ô¦¡¨Óקï·Æ¹««ü¼Ð¡G
Screen.MousePointer = vbHourglass
«ü¬£¨ì¦¹ÄݩʪºÈ¶È¯à¼vÅT¥Ø«eªºÀ³¥Îµ{¦¡¡C¦pªG²¾°Ê·Æ¹«´å¼Ð¨ì¥t¤@À³¥Îµ{¦¡ªº®à±©Îµøµ¡¤W¡Aì¨Óªº·Æ¹«´å¼Ð´N·|«³]¡C¦]¦¹¡A³o¤£ºâ¯u¥¿ªº¿Ã¹õÄÝ©Ê¡A³oÓ·§©À¤]¾A¥Î©óScreenÄÝ©Ê¡BActiveForm¤ÎActiveControl¡CActiveForm¬O°ßŪªºÄÝ©Ê¡A¨äActiveControl«h·|¶Ç¦^µ¹¨Ï¥Î¤¤¤§ªí³æªº¿é¤J¾nÂI¡]input focus¡^ªº±±¨î¶µ¤@Ó°Ñ·Ó¡C³q±`·|¤@°_¨Ï¥Î³o¤GÓÄÝ©Ê¡G
' ¦pªG¥Ø«eªºªí³æ¬OfrmCustomer¡A«h²M°£¦³µJÂIªº±±¨î¶µ ' On Error¬O¥²nªº¡A¦]¬°µLªk½T»{¨ä¬O§_¤ä´©TextÄÝ©Ê¡A©Î¬Æ¦Ü¹ê»Ú¤W¬°§@¥Î ¤¤±±¨î¶µ On Error Resume Next If Screen.ActiveForm.Name = "frmCustomer" Then Screen.ActiveControl.Text = "" End If
ªí³æ§Y¨Ï¨S¦³¿é¤JµJÂI¤]¥i§@¥Î¡CY¤w¸õ¨ì¥t¤@À³¥Îµ{¦¡¤¤,¡AScreenª«¥ó¤´Ä~Äò¶Ç¦^°Ñ·Ó¨ì¥Ø«e¦bÀ³¥Îµ{¦¡¤¤ªº³Ì«á¤@Óªí³æ¡A¨Ó·í°µ§@¥Î¤¤ªºªí³æ¡C½Ð°O±o¡AScreenª«¥óµLªk¬Ý¨ì¶W¥X¥Ø«eÀ³¥Îµ{¦¡¥H¥~ªºªF¦è¡C¦Ó¥Ø«eªºÀ³¥Îµ{¦¡(current application)¬O«ü°ß¤@¦b¨t²Î¤W°õ¦æªºµ{¦¡¡C¥H¤U¥i»¡¬OWin32µ{¦¡³]p¤Wºâ¬O¤@ºØ±`³W¡G¥ô¦óÀ³¥Îµ{¦¡³£¤£À³¸Óª¾¹D¨ä¥LÀ³¥Îµ{¦¡ªºª¬ºA©Î¥H¥ô¦ó¤è¦¡¨Ó¼vÅT¨ä¥L¦b¨t²Î¤W°õ¦æªºÀ³¥Îµ{¦¡¡C
¦L¥X¤å¦r
¡@
¤j³¡¥÷Visual BasicªºÀ³¥Îµ{¦¡¨Ã¤£·|ª½±µ¦bªí³æ¤WÅã¥Ü¤å¦r¡A¦Ó³q±`¬O¥HLabel±±¨î¶µ©ÎPictureBox±±¨î¶µ¨ÓÅã¥Ü¤å¦r¡A¤£¹L»{ÃѦp¦ó¦bªí³æ¤WÅã¥Ü¤å¤´¦³§U©ó¤F¸ÑVisual Basic³q±`¬O¦p¦ó³B²z¤å¦rªº¡C¦A¨Ó¡A³oùØ©Ò´£¤Î¥ô¦ó¦³Ãöªí³æø¹Ïªº«ü¥O¤ÎÄݩʤ]¦P¼Ë¾A¥ÎPictureBox±±¨î¶µ¡C
³Ì«n¥Î¨ÓÅã¥Ü¤å¦rªºÃ¸¹Ï¤èªk´N¬OPrint¤èªk¡C¦]¬°¨ä¦´Áªº¼Ë¤l¡A¸g¹L¦h¦~¨ÌµMµL¥ô¦óקï¡A¤´Ä~Äò³Q«O¯d¤U¨Ó¡A³oÓ«ü¥O¨ä¹ê¦¤w¬OBasic»y¨¥ªº¤@³¡¥÷¤F¡C¦]¬°¦´ÁªºMS-DOSµ{¦¡¬O¥HBasic¨Ó¼g¡A¦Ó·|¨Ì¨ä¨Ï¥ÎªÌ¤¶±ªº«ü¥O¦ÓÅܱo«Ü¤j¡A©Ò¥HVisual Basic¯à¤ä´©³oÓ¤èªk¬O«Ü«nªº¡C¬JµM²{¥NVisual Basicµ{¦¡³]p¨Ã¤£¦A¥õ¿à³oÓ«ü¥O¡A¤£¹L§Ú¤´±N¤¶²Ð¨ä°ò¥»ªº¯S©Ê¡G
»¡©ú
¦bª«¥óÂsÄý¾¹¤¤¬O§ä¤£¨ìPrint¤èªkªº¡A³oÓ«ü¥Oªº¥»½è»P¨ä±±¨î¶µ¤§»yªk¡]¸Õ·Q¤@¤U¦³«Ü¦h³¯±Ô¦¡¥i¥Î©óPrint¡A¹³³rÂI¡B¤À¸¹¤ÎTab ()¨ç¼Æ¡^¨ÓÁקKMicrosoft¤uµ{®v¦b¦¹±N¨ä¥]¬A¶i¨Ó¡A¦Ó¬O¦b°õ¦æ¶¥¬q¡APrint¤èªk¥iª½±µ¦bµ{¦¡»y¨¥¤¤°õ¦æ¡A¦Ó±N©Ò¦³³sÄò¤Î½ÆÂøªºª«¥ó¾É¦V»y¨¥°õ¦æªº®ø¯Óµø¬°¾ãÅé¡C
³q±`·|¨Ï¥ÎPrint¤èªk¨Ó°µªí³æ¥Î¤áºÝ°Ï°ì¤Wªº§Ö±¶¿é¥X¡]quick-and-dirty output¡^¡A¨Ò¦p¡G¥i¥H¥Î¥H¤U³oÓ²³æªºµ{¦¡½X¨ÓÅã¥Üªí³æ¥Ø«eªº¤j¤p¤Î¦ì¸m¡G
Private Sub Form_Resize() Cls ' «³]¦L¥Xªº¦ì¸m¨ì (0,0) Print "Left = " & Left & vbTab & "Top = " & Top Print "Width = " & Width & vbTab & "Height = " & Height End Sub
¤p¯µ³Z
¥i¨Ï¥Î¤À¸¹¨Ó¥N´À¡u&¡v¹Bºâ¤l¡A¥Î³r¸¹¨Ó¥N´ÀvbTab±`¼Æ¡C ¦p¬G·Nn¥Î¼Ð·Ç»yªk¥B«O«ùPrint¤èªk¯S©Ê©ú´·¡A«h¥i«Ü²³æ¦a´`Àô¨Ï¥Î¨ä¤Þ¼Æ¨Ã¶Ç¨ì¦Ûqªº¤èªk¡A©Î«ü¬£¨ìLabel¤¤ªºCaptionÄÝ©Ê¡C³o¼Ë¤@¨Ó¦p±N§Ö±¶¡]quick-and-dirty¡^¼Ëª©Âର¤@¯ëªºÀ³¥Îµ{¦¡«á¡A¥i¥H¸`¬Ù®É¶¡¡C
¦p¦P¤§«e§Ú´¿»¡©ú¹Lªº¡APrint¤èªkªº²£¥X¨ü¥Ø«eFont¤ÎForeColorÄÝ©ÊȪº¼vÅT¡A¹w³]ªº±¡ªp¤U¡ABackColorÄݩʨ䣷|¼vÅTPrint«ü¥O¡A¦]¬°¤å¦r³q±`·í¨äI´º¬°³z©ú®É¤~·|¦L¥X¡C¤j³¡¥÷ªº®ÉÔ¡A³oºØ±¡ªp¨Ã¤£·|µo¥Í°ÝÃD¡A¦]¬°³q±`·|¦L¦b°®²bªºªí³æ¤W¡A¦Ó³o¤]·|¦³§ó¦nªº°õ¦æµ²ªG¡A¦]¬°¶È»Ý¶Ç¿é¤å¦rªº¹³¯À¦Ó¤£¥Î¶ÇI´ºªºÃC¦â¡A¤£¹L¦p±ý©ó²M°£¤§«e¦P¤@¦ì¸m¤Wªº°T®§¡A¦P®É¤]¦L¥X°T®§¡A«h³]©wFontTransparentÄÝ©ÊȬ°False´N¥i°µ¨ì¡C§_«h¡A«h»Ýµ²§ô¦b¤W¼hªº°T®§¨ÓÅý¤G«h°T®§³£¬Ý¤£¨ì¡C
¤@¯ë¨Ó»¡¡A¨C¦¸Print«ü¥O«³]¥Ø«eø¹Ï¦ì¸mªºx-¶b¬°0¨Ã´£°ªy-¶b¡A¦p¦¹¤@¨Ó¡A¤U¤@Ó¦r¦ê´N·|¥ß§YÅã¥Ü¦b«e¤@Ó¤§¤U¡C¬d¸ßªí³æªºCurrentX¤ÎCurrentYÄݩʤ]¥iª¾¹D¤U¤@ÓPrint«ü¥OÅã¥Ü¨äµ²ªGªº¦ì¸m¡C¥¿±`ª¬ªp¤U¡AÂI(0,0)ªí¥Ü¥Î¤áºÝ°Ï°ìªº¥ª¤W¨¤¡]§Yªí³æÃä½u¤º¨ä¼ÐÃD¦C¤U¤èªº³¡¥÷¡^¡Cx-¶bªºÈ¬O±q¥ª¦V¥k»¼¼W¡A¦Óy-¶b¬O±q¤W¨ì¤U»¼¼W¡C¥i«ü¬£·sªºÈ¨ì³o¨ÇÄݩʤ¤¨Ó¦bªí³æ¤W¥ô¦ó¦a¤è¦L¥X¤å¦r¡G
' ¦bªí³æ¬ù¥¿¤¤¥¡ªº¦a¤èÅã¥Ü°T®§ CurrentX = ScaleWidth / 2 CurrentY = ScaleHeight / 2 Print "I'm here!"
¤£¹L³oÓµ{¦¡½X¨ä¹ê¤£·|Åý°T®§¥¿¦n¥X²{¦bªí³æªº¤¤¥¡¡A¦]¬°¦r¦êªº¨ä¥L³¡¥÷·|¦V¥k¥X²{©Ò¥H¥u¦³¤@¶}©lªº¦L¥XÂI¬O¦b¥¿¤¤¥¡¡Cnºë½T¦a±N¾ãÓ°T®§¸m¤¤¡A«h¥²»Ý±qªí³æªºTextHeight¤ÎTextWidth¤èªk¨Ó©w°ª«×¤Î¼e«×¡G
msg = "I'm here, in the center of the form." CurrentX = (ScaleWidth _ TextWidth(msg)) / 2 CurrentY = (ScaleHeight - TextHeight(msg)) / 2 Print msg
TextWidth¤ÎTextHeight¤èªk±`¥Î¥H¤F¸Ñ°T®§¬O§_¥i©ó©w½d³ò¤º¥X²{¡A¦Ó¦]¬°Print¤èªk¹ï¸ûªøªº¦r¦ê¨ÃµLªk¦Û°ÊÂ_¦æ¡A³oÓ¨BÆJ¦b»Ý¦L¥Xªí³æ®É´NÅã±o¯S§O¦n¥Î¡CnÀ±¸É¦¹¤@¤£¨¬ªº¦a¤è¡A¥i¥H¦bªÅ¥Õªºªí³æ¥[¤W¥H¤Uµ{¦¡½X¡A°õ¦æµ{¦¡«á«h¥i¥ô·N½Õ¾ãªí³æ¤j¤p¡C¹Ï2-10¥i¨£ªí³æ«½Õ¤j¤pªº±¡§Î¡C
¡@
Figure 2-10. ¹ï¸ûªøªº¤å¦r¦Û°ÊÂ_¦æ |
' ®æ¦¡¤ÆPrint¿é¥Xªº°Æµ{¦¡ Private Sub Form_Paint() Dim msg As String, pos As Long, spacePos As Long msg = "You often use the TextWidth and TextHeight methods" _ & " to check if a message can fit within a given area. " _ & vbCrLf & " This is especially necessary when you" _ & " print to a form, because the Print method doesn't" _ & " support automatic wrapping for long lines, and you" _ & " need to solve the problem through code." Cls Do While pos < Len(msg) pos = pos + 1 If Mid$(msg, pos, 2) = vbCrLf Then ' A CR-LF pair, print the string so far and reset variables. Print Left$(msg, pos - 1) msg = LTrim$(Mid$(msg, pos + 2)) pos = 0: spacePos = 0 ElseIf Mid$(msg, pos, 1) = " " Then ' A space, remember its position for later. spacePos = pos End If ' Àˬd¥Ø«e¬°¤î°T®§ªø«× If TextWidth(Left$(msg, pos)) > ScaleWidth Then ' The message is too long, so let's split it. ' If we just parsed a space, split it there. If spacePos Then pos = spacePos ' Print the message up to the split point. Print Left$(msg, pos - 1) ' Discard printed characters, and reset variables. msg = LTrim$(Mid$(msg, pos)) pos = 0: spacePos = 0 End If Loop ' Print residual characters, if any. If Len(msg) Then Print msg End Sub Private Sub Form_Resize() Refresh End Sub
¤W±ªºµ{¦¡½X¹ï¥ô¦ó¦r§Î³£¯à¨Ï¥Î¡A±z¥i¥H«Ø¥ß¤@Ó¥i±µ¨ü¥ô¦ó¦r¦ê¤Î¥ô¤@ªí³æ°Ñ·Óªº³q¥Î°Æµ{¦¡¨Ó·í§@½m²ß¡A¦p¦¹¤@¨Ó´N¯à©ó¤§«áªºÀ³¥Îµ{¦¡³£¥i¦A¨Ï¥Î¨ì¡C
¥t¤@ӫݸѨMªº°ÝÃD¬O»Ý©w°T®§³Ì¾A¦Xªº¦r«¬¤j¤p¡A³o¼Ë¤~¯à¦b¬J©wªº½d³ò¤º¥X²{¡C¦]¬°¤£ª¾¹D¥Ø«e¨Ï¥Î¦r«¬¥i¤ä´©ªº¤j¤p¡A©Ò¥H³q±`±o¨Ï¥ÎFor..Next°j°é¨Ó§ä³Ì¦X¾Aªº¤j¤p¡C¥H¤U³oÓ²³æªºµ{¦¡½d¨Ò¤¤¡A«Ø¥ß¤F¤@ӼƦ쪺®ÉÄÁ¡A¥B¥iÀH·N©ñ¤j©ÎÁY¤p¡A®É¶¡«h¬O³z¹LÁôÂêºTimer±±¨î¶µ¨Ó§ó·s¡G
Private Sub Form_Resize() Dim msg As String, size As Integer msg = Time$ For size = 200 To 8 Step -2 Font.Size = size If TextWidth(msg) <= ScaleWidth And _ TextHeight(msg) <= ScaleHeight Then ' ¤w§ä¨ì¾A¦Xªº¦rÅé¤j¤p¤F Exit For End If Next ' ±Ò°Êp®É¾¹ Timer1.Enabled = True Timer1.Interval = 1000 End Sub Private Sub Timer1_Timer() ' ¥H¥Ø«eªº¦r«¬³]©w¦L¥X¥Ø«eªº®É¶¡ Cls Print Time$ End Sub
Graphic¤èªk
¡@
Visual Basic´£¨Ñµ{¦¡¶}µo¦hºØø¹Ï¤èªk¡C¥i¥HµeÂI©Î½u¤]¥i¥Hµe§ó½ÆÂøªº´X¦ó¹Ï§Î¡A¨Ò¦p¡Gªø¤è§Î¡B¶ê§Î¤Î¾ò¶ê§Î¡C¨Ã¥i§¹¥þ´x±±½u±øÃC¦â¡B¼e«×¤Î«¬ºA¡A¤]¥i¥H¥Î©T©wªº¦â±m©Îªá¯¾¨Ó¶ñº¡©Ò¦³¹Ï§Î¡C
µLºÃ¦a¡A³Ì²³æªºÃ¸¹Ï¤èªk´N¬OCls¡C¨ä¥i²M°£ªí³æªºªí±¡A¦A¥HBackColorÄÝ©Ê©Ò©w¸qªºI´ºÃC¦â¶ñº¡¥L¡A¦A±N¨ä²¾°Ê¥Ø«eø¹Ïªº¦ì¸m¨ì®y¼Ð(0,0)¡C¦p«ü¬£·sȵ¹BackColorÄÝ©Ê¡A«hVisual Basic·|²M°£¥»¨ªºI´º¡A¦p¦¹¤@¨Ó«h¥Ã»·µL»Ý©ó§ïÅܪí³æI´ºÃC¦â«á¦A¤ÞµoCls¤èªk¡C
µeÂI
¡@
Pset¬O§ó¦n¥Îªº¤èªk¡A¥i¥Î¥Hקïªí³æ¤W³æ¤@¹³¯ÀªºÃC¦â¡C°ò¥»ªº»yªk¡A¥un«ü©wx©My¶b§Y¥i¡A¦Ó²Ä¤TÓ¿ï¾Ü©Ê°Ñ¼ÆY¤£¦P©óForeColorªºÈ«h¥i«ü©w¹³¯ÀªºÃC¦â¡G
ForeColor = vbRed PSet (0, 0) ' ¬õ¦â¹³¯À PSet (10, 0), vbCyan ' ¦V¥k²¾ªºÂźñ¦â¹³¯À
¦p¦P³\¦h¨ä¥Lø¹Ïªº¤èªk¡APset¥i¥ÎStep³oÓÃöÁä¦r¤ä´©¬Û¹ï¦ì¸m¡A·í¨Ï¥Î³oÓÃöÁä¦r®É¡A¦b¬A©·¤¤ªº¤GÓȱN·í§@¬O±q¥Ø«eø¹ÏÂI¡]§Y¥Ø«e¿Ã¹õ¤WCurrentX¤ÎCurrentY©Ò«üªº¦a¤è¡^¶}©lpºâªº¦a¤è¡C¥HPset¤èªkµeªºÂI«h·|Åܦ¨¥Ø«eªºÃ¸¹Ï¦ì¸m¡F
' ³]©w¶}©l¦ì¸m CurrentX = 1000: CurrentY = 500 ' ©µ¤ô¥½uµe10ÓÂI For i = 1 To 10 PSet Step (8, 0) Next
¨Ï¥ÎPset¤èªkªºµ²ªG¤]¨ü¨ä¥Lªí³æÄݩʪº¼vÅT¡A¨Ò¦pDrawWidth¡A±N¦¹Äݩʳ]¬°¤j©ó1¡]¹w³]È¡^ªºÈ«h¥iµe¥X¸û¤jªºÂI¡C½Ðª`·N·í©Ò¦³Ã¸¹Ï³æ¦ì¬°twip®É¡A¨äȬO¥H¹³¯Àpºâ¡C·í¨Ï¥Î¤j©ó1ªºÈ¡A®y¼Ð±N¶Çµ¹Pset¤èªk·|³Qµø¬°¤ñ¸û¤jªºÂI¡]¨ä¹ê¸Ó»¡¬O¤@Ó¶ê¤F¡^ªº¤¤¥¡¡C½Ð¸Õ¸Õ¬Ý¥H¤U´X¦æµ{¦¡½X¨Ó°µ±m¦âªº®ÄªG¡G
For i = 1 To 1000 ' ¶Ã¼Æ³]©wÂIªº¼e DrawWidth = Rnd * 10 + 1 ' ¥H¶Ã¼Æ¨ú®y¼ÐȤÎÃC¦â¨Óµe¤@ÓÂI PSet (Rnd * ScaleWidth, Rnd * ScaleHeight), _ RGB(Rnd * 255, Rnd * 255, Rnd * 255) Next ' ¦n²ßºD¡GÁÙ쬰¹w³]È. DrawWidth = 1
Point¤èªk©MPset¤èªk«Ü¹³¡A¬O¥Î¨Ó¶Ç¦^¬J©w¹³¯ÀªºRGBÃC¦âªºÈ¡Cn¤F¸Ñ³oÓ¤èªk¦p¦ó¨Ï¥Î¡Aº¥ý¥i«Ø¥ß¤@Ó¦³Label1±±¨î¶µªºªí³æ¡Aµe¤W¤@¨Ç¹Ï¡]¥i¥Î¤§«eªº¤@¨Çµ{¦¡¡^¡AµM«á¦A¥[¤W¥H¤Uªº°Æµ{¦¡¡G
Private Sub Form_MouseMove (Button As Integer, _ Shift As Integer, X As Single, Y As Single) Label1.Caption = "(" & X & "," & Y & ") = " _ & Hex$(Point(X, Y)) End Sub
°õ¦æ¦¹µ{¦¡¡A¨Ã²¾°Ê·Æ¹«´å¼Ð¨ì¦³ÃC¦âªºÂI¨ÓÅã¥Ü®y¼Ð¤ÎÃC¦âªºÈ¡C
µe½u¤Îªø¤è§Î
¡@
±µ¤U¨Ó¤¶²ÐLine¤èªk¡C³o¬Oӫܦn¥Îªº«ü¥O¡A¨ä»yªkªº¦h¼Ë©Ê¡A¥u»Ý´£¨Ñ¶}©l¤Îµ²§ôªº®y¼Ð´N¥i¥Hµe¥Xª½½u¡A¥t¥~¦A¥[¤WÃC¦âªºÈ´N¤j¥\§i¦¨¤F¡]¦p¬Ù²¤ÃC¦âªºÈ¡A«h·|¨Ï¥Î¥Ø«eForeColorªºÈ¡^¡G
' ¥Hªí³æ¤G¹ï¨¤µe±K±×¯¾¤Î¬õ¦âªº"X" ' Line¤èªk·|¨ü¥Ø«eDrawWidth¤§³]©w¼vÅT DrawWidth = 5 Line (0, 0) _ (ScaleWidth, ScaleHeight), vbRed Line (ScaleWidth, 0) _ (0, ScaleHeight), vbRed
¦p¦PPset¤èªk¤@¼Ë¡ALine¤èªk¤]¤ä´©Step³oÓÃöÁä¦r¨Ó«ü©w¬Û¹ï¦ì¸m¡CStepÃöÁä¦r¥i©ñ¦b¥ô¤@²Õ®y¼Ð¤§«e¡A©Ò¥H¥i¥ô·N²V¦Xµ´¹ï¦ì¸m©M¬Û¹ï¦ì¸m¡C¦p¬Ù²¤²Ä¤@Ӥ޼ơA«h·|¥H¥Ø«eªºÃ¸¹Ï¦ì¸m¶}©lµe½u¡G
' µe¤T¨¤§Î Line (1000, 2000)- Step (1000, 0) ' ¤ô¥½u Line -Step (0, 1000) ' ««ª½½u Line -(1000, 2000) ' µe¤W¤T¨¤§Î³Ì«á¤@±ø½u
Line¤èªkªºµ²ªG¤]¨üªí³æªº¥t¤@ÄݩʼvÅT¡ÐDrawStyle¡A¹w³]Ȭ°0 (¹ê½u)¡A¤£¹L¤]¥iµeµê½u¡A½Ð¬Ý¹Ï2-11¡Cªí2-2¦C¥X©Ò¦³ªº½u±ø«¬ºA¡G
¡@
Figure 2-11 DrawStyleÄݩʤ£¦P³]©wªºµ²ªG |
ªí2-2 DrawStyleÄݩʪº±`¼Æ |
±`¼Æ | È | ±Ôz |
---|---|---|
vbSolid | 0 | ¹ê½u(¹w³]È) |
vbDash | 1 | ¥Ñ ¢w ¢w ©Ò§Î¦¨ªº½u |
VbDot | 2 | ¥Ñ - ©Ò§Î¦¨ªº½u |
VbDashDot | 3 | ¥Ñ ¢w ©M - ¤ÏÂÐ¥X²{©Ò§Î¦¨ªº½u |
VbDashDotDot | 4 | ¥Ñ ¢w ©M -- ¤ÏÂÐ¥X²{©Ò§Î¦¨ªº½u |
VbInvisible | 5 | ³z©ú |
VbInsideSolid | 6 | ¤º¹ê½u |
½Ðª`·NDrawStyleÄݩʶȷ|¦b¨äȬ°1-¹³¯À®É¥i¼vÅTø¹Ïµ²ªG¡F¦p¬°¨ä¥LªºÈ¡A«hDrawStyleÄÝ©Ê·|³Q©¿²¤¥B½u±ø³£·|¥Î¹ê½u¡C·s¼WB¬°Line¤èªk²Ä¥|ӰѼƨӵe¯x§Î¡F¦b³oӮרҤ¤¡A³o¤GÓÂI¬O¥ô¦ó¹ï¨¤½uªº®y¼Ð¡G
' ÂŦâ¯x§Î¡A¼e2000 twip ¡A°ª1000 twip Line (500, 500)- Step (2000, 1000), vbBlue, B
¯x§ÎªºÃ¸»s¤è¦¡·|¨ü¨ì¥Ø«eDrawWidth¤ÎFillStyleÄÝ©Ê©Ò³]©wªºÈ¤§¼vÅT¡C
³Ì«á¡A¥i¨Ï¥ÎBF¤Þ¼Æ¨Óµe¶ñº¡ªº¯x§Î¡A«Ø¥ßµL¶ñº¡¤Î¶ñº¡ªº¯x§Î¤§¥\¯à¥iÅý±z«Ø¥ß¤@¨Ç¦³½ìªº®ÄªG¡A¨Ò¦p¡G¥i¥Hø»sªí³æ¤W3-D¶À¦â¯B°Ê¯x§Î¡A½Ð¬Ý¥H¤U¤T¦æµ{¦¡½X¡G
' ¦Ç¦âªº¯x§Î¥i°µ³±¼v Line (500, 500)-Step(2000, 1000), RGB(64, 64, 64), BF ' ¥Õ¦â¯x§Î¬°ªí Line (450, 450)-Step(2000, 1000), vbYellow, BF ' ¥[¤W¶Â¦â®Ø½u Line (450, 450)-Step(2000, 1000), vbBlack, B
ÁöµM¥i¥H¥ÎBF¤Þ¼Æ¨Óø»s¶ñº¡ªº¯x§Î¡AVisual BasicÁÙ¬O´£¨Ñ¤F§ó°ª¶¥ªº¶ñº¡¤è¦¡¡G¥i¥H³]©wFillStyleÄݩʨӰµ¶ñº¡¡Aµ²ªG½Ð°Ñ¬Ý¹Ï2-12¡C«Ü¦³½ì¦a¡AVisual Basic¹ïÓ§OÃC¦â´£¨ÑÓ§OªºÃC¦âÄݩʨѶñº¡°Ï°ì¨Ï¥Î¡A¦ÓFillColor«h¤¹³\¥H¤@ºØÃC¦âµe¯x§Îªº½ü¹ø¡A¨Ã¥Î¨ä¥LÃC¦â¨Óµe¨ä¤º³¡¡C¥H¤U§Y§Q¥Î¤@¯S©Ê¡A¦]¦¹¥u»Ý¤G¦æ´N¥i«¼g¥ý«eµ{¦¡½Xªº¨Ò¤l¡G
Line (500, 500)-Step(2000, 1000), RGB(64, 64, 64), BF FillStyle = vbFSSolid ' §@¶ñº¡ªº¯x§Î FillColor = vbYellow ' ¤W¦â Line (450, 450)-Step(2000, 1000), vbBlack, B
¡@
¹Ï2-12 FillStyleÄÝ©Ê©Ò´£¨Ñªº8ºØ¼Ë¦¡ |
FillStyleÄÝ©Ê¥i³Q«ü©wªºÈ¡A½Ð°Ñ¬Ýªí2-3¡C
ªí2-3 FillStyleÄݩʪº±`¼Æ |
±`¼Æ | È | ±Ôz |
---|---|---|
vbFSSolid | 0 | ¹ê¤ß |
vbFSTransparent | 1 | ³z©ú |
vbHorizontalLine | 2 | ¤ô¥½u |
vbVerticalLine | 3 | ««ª½½u |
vbUpwardDiagonal | 4 | ¥ª¤W¨ì¥k¤Uªº±×½u |
vbDownwardDiagonal | 5 | ¥ª¤U¨ì¥k¤Wªº±×½u |
vbCross | 6 | ««ª½¥æ¤e½u |
vbDiagonalCross | 7 | ¹ï¨¤¥æ¤e½u |
µe¶ê¡B¾ò¶ê¡B¤Î©·
¡@
³Ì«án¨Ó¤¶²Ð³Ì½ÆÂøªºCircle¤èªk¡A¨ä¥i¥Hµe¶ê¡B¾ò¶ê¡B©·¡B¬Æ¦Ü¬OPIE¹Ï¡Cµe¶ê¬O³oÓ¤èªk³Ì²³æªº°Ê§@¤F¡A¦]¬°´X¥G¤£»Ý«ü©w¶ê¤ß¤Î¥b®|¡G
' ¥b®|¬°1000¹³¯À¡A±µªñªí³æªº¥k¤W¨¤¡G Circle (1200, 1200), 1000
Circle¤èªk·|¨üDrawWidth¡BDrawStyle¡BFillStyle¤ÎFillColor¥Ø«eªºÄÝ©ÊȼvÅT¡A³oªí¥Ü¥i¥Îµe¸û²ÓÃä½uªº¶ê¨Ã¥Îªá¯¾¶ñº¡¹Ï§Î¡C¶êªºÃä½u³q±`¬O¥H¥Ø«eªºForeColorªºÈ¨Óµe¡A¤£¹L¤]¥i¥H²Ä¥|Ӥ޼ƨӧïÅÜ¥¦¡G
' 3¹³¯À¼e½u¦âÃä½uªº¶ê¡A¨Ã¥Î¶À¦â¶ñº¡ DrawWidth = 3 FillStyle = vbFSSolid FillColor = vbYellow Circle (1200, 1200), 1000, vbGreen
¤Wzªº¨Ò¤l¥ô¦ó¿Ã¹õ¤Î¥ô¦ó¸ÑªR«×¤U³£¥iµe¤@ӫܧ¹¬üªº¶ê¡A¦]¬°Visual Basic·|¦Û°Êªux¤Îy¶b¨Ópºâ¤£¦Pªº¹³¯À±K«×¡C¦Ü©óµe¾ò¶ê¡A«h¥²»Ý¸õ¹L¥t¥~¤GÓ¥i¦Û¥Ñ¿ï¾Üªº¤Þ¼Æ¡]µy«á·|¦A§@¸ÑÄÀ¡^¡A¨Ã¦b«ü¥Oµ²§ô·s¼W¤@ӱײv¡C±×²v´N¬O¾ò¶êªºy¶b°£¥Hx¶b¡C¦Ü©ó§ó½ÆÂøªº³¡¥÷¡A¦¹¤èªkªº²Ä¤TÓ¤Þ¼ÆÈÀ³¤j©ó³o¤GÓªº¥b®|È¡C¦pªG§Æ±æ¦b¯x§Îªº½d³ò¤ºµe¤@Ó¾ò¶ê¡A«h¥²»Ý¯S§Oª`·N¡C¦¹¤@¥i«ÂШϥΪº°Æµ{¦¡¥i²¤Æµe¾ò¶êªº»yªk¡G
Sub Ellipse(X As Single, Y As Single, RadiusX As Single, _ RadiusY As Single) Dim ratio As Single, radius As Single ratio = RadiusY / RadiusX If ratio < 1 Then radius = RadiusX Else radius = RadiusY End If Circle (X, Y), radius, , , , ratio End Sub
Circle¤èªk¥un²Ä¤@Ӥγ̫á¤@Óªº¤Þ¼Æ¡]¤§«e¸õ¹Lªº¨º¤GӤ޼ơ^§Y¥iµe¶ê¤Î¾ò¶êªº©·§Î¡C³o¨Ç¤Þ¼ÆªºÈ´N¬Oµê½uºc¦¨ªº¨¤ªº¶}©l¤Îµ²§ôªº¦a¤è¡A¥i±N©·¤GºÝÂI»P¹Ï§Î¤¤ÂI³s°_¨Ó¡C³oÓ¨¤ªº©·«×¬O¥H°f®É°wªº¤è¦Vpºâ¡CÁ|Ó¨Ò¤l¨Ó»¡¡A¥i¥H¨Ì¦¹¨Óµe¤@Ó¥|¤À¶ê¡G
Const PI = 3.14159265358979 Circle (ScaleWidth / 2, ScaleHeight / 2), 1500, vbBlack, 0, PI / 2
·íµM¦p±ýµeªº¬O¾ò¶êªº©·¤]¥i¥H¥[¤W±×²vªº¤Þ¼Æ¡CCircle¤èªk¬Æ¦ÜÁÙ¥i¥Hø»s®°§Î¹Ï¡A¤]´N¬O©·§Î¥H¥b®|»P¶ê§Î©Î¾ò¶êªº¶ê¤ß¬Û³sªº¹Ï§Î¡Cµe³oӹϧλݫü©w²Ä¤@¤Î³Ì«á¤@Ó¤Þ¼ÆȬ°t¡C¹Ï2-13Åã¥Ü¤§¡u ¦³¯Ê¤fªº¡v®°§Î¹Ï¬O¥H¦p¤Uµ{¦¡½X©Ò°µªº¡G
' µe¦³¯Ê¤fªº®°§Î¹Ï ' ½Ðª`·N¤£¯à«ü©wNulltªºÈ ' but you can express it as -(PI * 2). Const PI = 3.14159265358979 FillStyle = vbFSSolid FillColor = vbBlue Circle (ScaleWidth / 2 + 200, ScaleHeight / 2 - 200), _ 1500, vbBlack, -(PI * 2), -(PI / 2) FillColor = vbCyan Circle (ScaleWidth / 2, ScaleHeight / 2), _ 1500, vbBlack, -(PI / 2), -(PI * 2)
¡@
¹Ï2-13 µe®°§Î¹Ï |
DrawModeÄÝ©Ê
¡@
¦]¬°¨ì¥Ø«e¬°¤î©Ò¤¶²ÐªºÄݩʤΤèªk¨Ã¤£¨¬°÷¡A©Ò¥H·í¼g¹Ï§Î±K¶°ªºÀ³¥Îµ{¦¡¤´»Ý¨Ó¬Ý¬Ýªí³æªº¥t¤@ÓÄÝ©Ê¢wDrawMode¡A³oÓÄݩʥΥH«ü©w¹Ï§Î»Pªí³æ¤W¹³¯Àªº¤¬°ÊÃö«Y¡CÁöµMªí³æ¤W©Ò¦³½u±ø¡B¶ê¤Î©·©Ò¦³ªº¹Ï¤§¹w³]ȳ£¥i¥H«Ü²³æ³Q§ó§ï¡A¤£¹LÀ³¸Ó¤£·|±`³o»ò°µ¡C¨Æ¹ê¤WDrawModeÄÝ©Ê©ó²V¦X¨Ï¥Î³o¨Çì´N¦bªí³æ¤Wªº¹Ï§Î®É´N¥i¼W²K³\¦hÅܤơC¡]ªí2-4¦C¥X¦UºØ®ÄªGªºÈ¡^
ªí2-4 DrawModeÄݩʪº±`¼Æ |
±`¼Æ | È | ±Ôz | ¦ì¤¸¹Bºâ¤l(S=¿Ã¹õ¡AP=µeµ§) |
---|---|---|---|
vbBlackness | 1 | ¿Ã¹õÃC¦âȳ£³]¦¨0(µeµ§ÃC¦â¥¼¨Ï¥Î) | S= 0 |
VbNotMergePen | 2 | OR¹Bºâ¤l¥Î©óµeµ§ÃC¦â¤Î¿Ã¹õÃC¦â¡Aµ²ªG·|¬Û¤Ï¡]¦]¬°¥Î¤FNOT¹Bºâ¤l¡^ | S= Not(S Or P) |
vbMaskNotPen | 3 | »Pµeµ§ÃC¦â¬Û¤Ï¡]¥Î¤FNOT¹Bºâ¤l¡^¡A¦]¥ÎAND¹Bºâ¤l©Ò¥Hµ²ªG¬O¿Ã¹õÃC¦â | S= S And Not P |
vbNotCopyPen | 4 | »Pµeµ§ÃC¦â¬Û¤Ï¡C | S= Not P |
vbMaskPenNot | 5 | »P¿Ã¹õÃC¦â¬Û¤Ï¡]¦]¨Ï¥ÎNOT¹Bºâ¤l¡^¡A¦]AND¹Bºâ¤l¡A¨Ï¥Îµeµ§ÃC¦â | S= Not S And P |
vbInvert | 6 | ¿Ã¹õÃC¦â³]¬Û¤Ï¡]µeµ§ÃC¦â¤£¨Ï¥Î¡^ | S= Not S |
vbXorPen | 7 | XOR¹Bºâ¤l¥Î©ó¿Ã¹õ¤Îµeµ§ÃC¦â | S= S Xor P |
vbNotMaskPen | 8 | AND¹Bºâ¤l¥Î©ó¿Ã¹õ¤Îµeµ§ÃC¦â¡A¦Óµ²ªG¬O¬Û¤Ïªº¡]¦]¨Ï¥ÎNOT¹Bºâ¤l¡^ | S= Not (S And P) |
vbMaskPen | 9 | AND¹Bºâ¤l¥Î©ó¿Ã¹õ¤Îµeµ§ÃC¦â | S= S And P |
vbNotXorPen | 10 | XOR¹Bºâ¤l¥Î©ó¿Ã¹õ¤Îµeµ§ÃC¦â¡A¦Óµ²ªG¬O¬Û¤Ïªº¡]¦]¨Ï¥ÎNOT¹Bºâ¤l¡^ | S= Not (S Xor P) |
vbNop | 11 | µL¥ô¦ó¹Bºâ¤l¡]¨Æ¹ê¤W¬OÃö³¬Ã¸¹Ï¡^ | S=S |
vbMergeNotPen | 12 | µeµ§ÃC¦â¬Û¤Ï¡]¦]¨Ï¥ÎNOT¹Bºâ¤l¡^¡A¨Ï¥ÎOR¹Bºâ¤l©óµ²ªG»P¿Ã¹õÃC¦â | S= S Or Not P |
vbCopyPen | 13 | ForeColorÄÝ©ÊÈ©Ò«ü©wªºÈ¨Óµe¹Ï | S= P |
vbMergePenNot | 14 | ¿Ã¹õÃC¦â¬Û¤Ï¡]¦]¨Ï¥ÎNOT¹Bºâ¤l¡^¤§«áNOTÀ³ºâ¤l¦A¥Î©óµeµ§ÃC¦â | S = Not S Or P |
vbMergePen | 15 | OR¹Bºâ¤l¥Î©ó¿Ã¹õÃC¦â¤Îµeµ§ÃC¦â | S= S Or P |
vbWhiteness | 16 | ¿Ã¹õÃC¦â§¡¬°1¡]µeµ§ÃC¦â¤£¨Ï¥Î¡^ | S=-1 |
n¤F¸Ñ¨C¤@ºØ¹Ï¨s³º¬O«ç»ò°µªº¡A»Ý¥ý°O±oÃC¦â¬O³Ì«á¸g¥Ñ¦ì¤¸¥X²{ªº¡A©Ò¥H°£¤F0»P1ªº¦ì¤¸«¬¹Bºâ¤l¨ÃµL¥iµ²¦Xµeµ§ÃC¦â¤Îªí³æ쥻ÃC¦â¤§¹Bºâ¤l¡C¦pªG¥H¦¹Æ[ÂI¦A¨Ó¬Ý¬Ýªí2-4¡A´N·|¤ñ¸û²M·¡³Ì¥kÃ䨺¤@¦æªº·N«ä¤F¡A¤]¥i¥H¥Î¨Ó³]©wø¹Ï«ü¥Oªº¹w´Áµ²ªG¡C¨Ò¦p¡A¦pªG¦bÂŦ⪺I´ºÃC¦â¡]¤Q¤»¶i¦ìªºÈÀ³¬°&HFFFF00¡^¤Wnµe¤@Ó¶À¦âªºÂI¡]¤Q¤»¶i¦ìªºÈÀ³¬°&HFFFF¡^¡A¥i¬Ý¨£¥H¤Uªºµ²ªG¡G
vbCopyPen | ¶À¦â(©¿²¤¿Ã¹õÃC¦â) |
vbXorPen | µµ¦â (&HFF00FF) |
vbMergePen | ¥Õ¦â (&HFFFFFF) |
vbMaskPen | ºñ¦â(&H00FF00) |
vbNotMaskPen | µµ¦â (&HFF00FF) |
¤£¦Pªºµe¹Ï¼Ò¦¡¤]¥i¥H²£¥Í¬Û¦Pªºµ²ªG¡A¯S§O¬O¦b¨Ï¥Î¹ê¤ßÃC¦âªº®ÉÔ¡]½Ð¬Ý¤W±¤ÎvbNotMaskPenªº½d¨Ò¡^¡A¦pªG°Ý¨ì»¡¡G¡u¬O§_¹ï©Ò¦³ªº¼Ò¦¡³£n¶OºÉ¤ß«ä¡H¡vµª®×¬O¡u¬Oªº¡v¤Î¡u¤£¡v¡C¦pªG¥u¬O¼g²³æµL¹Ï§Î²£¥ÍªºÀ³¥Îµ{¦¡³q±`¬OµL»Ý¾á¤ß¥LÌ¡A¦Ó¦pªG¬O§@¤@¨Ç°ª¶¥ªº¹Ï§Î³B²z«h¦Ü¤Ö»Ýª¾¹DVisual Basic´£¨Ñ¨º¨Ç¤è¦¡¡C
DrawModeÄݩʳ̦n¥Îªº¦a¤è´N¬O¯à®ø¥hÃä½t¡A¥Î·Æ¹«¦Aµe©Î½Õ¾ã·s¹Ï§Î¦Ó¤£¼vÅT¤§¤Uªº¨ä¥L¹Ï¡C¨C·í¦bMicrosoft¤pµe®a©Î¥ô¦óWindowsø¹Ïµ{¦¡¤¤µe¹Ï¡A§Y¨Ï¤£¬Æ¤F¸Ñ¤]³£¯à¨Ï¥Î¾ó¥ÖÀ¿ªº¥\¯à¡C¦pªG°Ý¨ì¡G·í¥H·Æ¹«©ì¦²¯x§Îªº¤@¨¤®É¨s³ºµo¥Í¤F¨º¨Ç¨Æ¡HMicrosoft¤pµe®a¬O§_À¿¥h³oÓ¯x§ÎµM«á©ó¥t¤@Ó¦ì¸m¦Aµe¤@Ó¯x§Î¡H¦bVisual BasicÀ³¥Îµ{¦¡¤¤n¦p¦ó¨Ï¥Î¬Û¦Pªº¯S©Ê¡H³o¨Çµª®×³£«Ü²³æ¡A¦Ó¥B¬O¥HDrawModeÄݩʬ°°ò¦¡C
³Z¬¦b©ó¹ï¿Ã¹õ¤Î¦P¼Ëªºµeµ§ªºÈ¥ÎXOR¹Bºâ¤l¤G¦¸¡A²Ä¤G¦¸ªºXOR·|©R¥O¿Ã¹õ¦^ÂÐ쥻ªºÃC¦â¡]¦p«D±`¼ô±x¨Ï¥ÎÅÞ¿è¹Bºâ¤l¡A³oÀ³¸Ó¤£·|¤ÓÃø¡A¦pªG¤£¼ô¡A«h½Ð¦h§@´X¦¸¸ÕÅç¡^¡C¦]¦¹¡A¥un³]©wDrawModeȬ°7-vbXorPen¡FµM«á²Ä¤@¦¸¥iµe¥X¯x§Î¡]©Î½u±ø¡B¶ê¡B©·µ¥µ¥¡^¡A²Ä¤G¦¸«h¥i¥H±N¨ä®ø¥h¡C·í¨Ï¥ÎªÌ³Ì«áÄÀ©ñ·Æ¹«´å¼Ð®É¡A³]©wDrawModeÄݩʬ°13-vbCopyPen¦bªí³æ¤Wµe³Ì«á¤@Ó¯x§Î¡C¤U±ªºµ{¦¡¥i¥Î¨Ó¸ÕÅç¤@¤U¾ó¥ÖÀ¿ªº¥\¯à¡G¥i¥H©ì¦²·Æ¹«¥ªÁäµe¤@ӪŪº¯x§Î¡]¥H¶Ã¼Æ²£¥Íªº½u±ø¼e«×¤Î¦â±m¡^¡A¦A©ì¦²·Æ¹«¥kÁä¨Ó¶ñº¡¦â±m¡C
' Form-levelÅÜ¼Æ Dim X1 As Single, X2 As Single Dim Y1 As Single, Y2 As Single ' ¦pªG§ÚÌ¥¿©ì¦²¤@Óªø¤è§ÎÈ·|¬OTrue Dim dragging As Boolean Private Sub Form_Load() ' ¦b¤@ӶªºI´º¤¤Ã¸¹Ïªº®ÄªG¸û¦n BackColor = vbBlack End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button And 3 Then dragging = True ' Remember starting coordinates. X1 = X: Y1 = Y: X2 = X: Y2 = Y ' ¥Î¶Ã¼Æ²£¥ÍÃC¦â¤Î¼e«× ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) DrawWidth = Rnd * 3 + 1 ' µeªø¤è§Î¥ÎXor¼Ò¦¡ DrawMode = vbXorPen Line (X1, Y1)-(X2, Y2), , B If Button = 2 Then ' ¶ñº¡¦âªºªø¤è§Î FillStyle = vbFSSolid FillColor = ForeColor End If End If End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If dragging Then ' §R°£Âªºªø¤è§Î¡]¥ÎXor¼Ò¦¡«½Æ¦P¤@Ó©R¥O¡^ Line (X1, Y1)-(X2, Y2), , B ' µe¥X·sªº®y¼Ð X2 = X: Y2 = Y Line (X1, Y1)-(X2, Y2), , B End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If dragging Then dragging = False ' ¨M©w§¹¦¨µe¥Xªø¤è§Î DrawMode = vbCopyPen Line (X1, Y1)-(X, Y), , B FillStyle = vbFSTransparent End If End Sub
ScaleModeÄÝ©Ê
¡@
ÁöµMtwip¬OVisual Basic¦b¿Ã¹õ¤W©ñ¸mª«¥ó¤Î½Õ¾ã¤j¤pªº¹w³]´ú¶q³æ¦ì¡A¦ý¤£¬O°ß¤@ªº³æ¦ì¡C¨Æ¹ê¤W¡Aªí³æ¤Î¤@¨Ç¨ä¥L¥i·í¦¬¯Ç¾¹ªº±±¨î¶µ¡]¨Ò¡GPictureBox±±¨î¶µ¡^¡A³£¦³ScaleModeÄÝ©Ê¥i¨Ñ©ó³]p©Î°õ¦æ¶¥¬q¤¤³]©w¡A¥i³]©wªºÈ¸Ô¦C©óªí2-5¡C
ªí2-5 ScaleModeÄݩʪº±`¼Æ |
±`¼Æ | È | ±Ôz |
---|---|---|
VbUser | 0 | ¨Ï¥ÎªÌ¦Ûq |
VbTwips | 1 | Twip¡A¬°¤¦Ê¤»¤Q¤C¤À¤§¤@¤½¤À |
VbPoints | 2 | ÂI(¨C¤@^¦T72ÂI) |
VbPixels | 3 | ¹³¯À |
VbCharacters | 4 | ¦r¤¸ (¤ô¥=120³æ¦ìtwip¡A««ª½=240 twips |
VbInches | 5 | ^¦T |
VbMillimeters | 6 | ¤½Íù |
VbCentimeters | 7 | ¤½¤À |
VbHimetric | 8 | Himetric¡]1000³æ¦ì¡×1¤½¤À¡^ |
ªí³æª«¥ó¦³¤GºØ¤èªk¥i»´©öÂà´«¥ô¦ó¤£¦Pªº´ú¶q³æ¦ì¡AScaleX¤èªk¥i¨Ñ¤ô¥´ú¶q¦ÓScaleY¤èªk¥i¨Ñ««ª½´ú¶q¡A¨ä»yªk¬O¬Û¦Pªº¡G¶Ç»¼¤@ӻݳQÂà´«ªºÈ¡]¨Ó·½È¡^¡A¥Îªí2-5¤¤¥ô¤@±`¼Æ¨Ó«ü©w¨Ó·½Èªº¨Ï¥Î³æ¦ì¡]fromscale°Ñ¼Æ¡^¡A¦A¥H¥t¤@Ó±`¼Æ¡]toscale°Ñ¼Æ¡^«ü©wÂà´««áªº³æ¦ì¡C¦p¬Ù²¤¤Ffromscale°Ñ¼Æ¡A«h·|¨Ï¥ÎvbHimetric¡A¦Ó¦p¬Ù²¤¤Ftoscale°Ñ¼Æ¡A«h·|¥H¥Ø«eScaleModeÄÝ©ÊȬ°¨äÈ¡C
' ªuµÛX®y¼Ð¤@Ópixel¬O¦h¤Ötwip¡H Print ScaleX(1, vbPixels, vbTwips) ' µe¥X¤@Ó50x80 pixelªø¤è§Î ' ¦bªí³æªº¥ª¤W¨¤¤£ºÞ«ü©wªºScaleMode Line (0, 0)-(ScaleX(50, vbPixels), ScaleY(80, vbPixels)), _ vbBlack, B
ª`·N
ScaleX¤ÎScaleY¤èªk´£¨Ñ¬Û¦Pªº¥\¥Î¡A¦p¦P¿Ã¹õª«¥ó¤¤TwipsPerPixelX¤ÎTwipsPerPixelYÄݩʤ@¼Ë¡A¬O¬°¨ä¥L´ú¶q³æ¦ì¤u§@¡A¦ÓµL»Ý¥h¼gÂà´«ªºµ{¦¡½X¡C°ß¤@»ÝÄ~Äò¨Ï¥ÎScreenªºÄݩʬO·í¦bBAS¼Ò²Õ¤¤¼gµ{¦¡½X¡]¦p¡G¤@¯ëªº¨ç¼Æ©Îµ{§Ç¡^¤S¨S¦³¥ô¦óªí³æ¥i°Ñ·Ó®É¡C
ScaleModeÄÝ©Ê»P¨ä¥L¥|ÓÄÝ©Ê«D±`¦³¬ÛÃö©Ê¡CScaleLeft¤ÎScaleTop¬Û·í©óªí³æªº¥Î¤á°Ï°ì¥ª¤W¤è¹³¯Àªº(x,y)È¡A³q±`³]©w¬°0¡CScaleWidth¤ÎScaleHeight«h¬Û¸û©ó¥Î¤á°Ï°ì¥k¤U¨¤ªº¹³¯ÀÈ¡C¦p³]©w¤£¦PªºScaleMode¡A«h³o¤GÓÄݩʥߨè·|¤ÏÀ³¥X·sªº³]©wÈ¡C¨Ò¦p¡G°²³]³]©wScaleModeȬ°3-¹³¯À¡A¨º»ò¥h¬d¸ßScaleWidth¤ÎScaleHeightÈ´N¥iª¾¹D¥Î¤á°Ï°ì¥H¹³¯À¬°³æ¦ìªº¤j¤p¤F¡C½Ð°O±o¡A§Y¨Ï¥Ø«eªºScaleMode¬°1-Twips¡AScaleWidth¤ÎScaleHeightÄݩʶǦ^ªºÈ¤]·|¤£¦P©óªí³æªºWidth»PHeightÄÝ©Ê¡A¦]¬°«áªÌ¬Oµøµ¡ªºÃä®Ø¤Î¼ÐÃD¦Cªº®y¼Ð¡A¬O¦b¥Î¤á°Ïªº¥~³¡¡A¦pªG¤F¸Ñ¤F³o¨Ç¼Æ¶q¶¡ªºÃö«Y¡A´N¥i¥H¾É¥X¤@¨Ç«Ü¦³¥Îªºªí³æ¸ê°T¡C
'¦bªí³æ¼Ò²Õ¤º³¡°õ¦æ¥H¤Uµ{¦¡½X ' ½T»{ScaleWidth¤Îand ScaleHeight¶Ç¦^twip ' ¡]Y¨Ï¥Î¹w³]È«h¤U¤@¦æµL¥Î¡^ ScaleMode = vbTwips ' pºâÃä®Øªº¼e«×¬O¦h¤Öpixels BorderWidth = (Width _ ScaleWidth) / Screen.TwipsPerPixelX / 2 ' pºâ¼ÐÃD¦Cªº°ª«×¬O¦h¤Öpixels ' (Assumes that the form has no menu bar) CaptionHeight = (Height _ ScaleHeight) / _ Screen.TwipsPerPixelY _ BorderWidth * 2
ScaleModeÄÝ©ÊȪº«ü¬£¥i¥H¬O¥ô·NÈ¡A¤£¹L³Ì±`¨Ï¥Îªº¬O Twip ¤Î ¹³¯À ¡C ¹³¯À ¦b¨ú¦^¤l±±¨î¶µªº¹³¯À®y¼Ð®É´N«Ü¦³¥Î³B¡A¥i¥Î¨Ó°õ¦æ¤@¨Ç§t©óWindows API©I¥s¨ç¦¡ªº°ª¶¥Ã¸¹Ï«ü¥O¡C
¨Ï¥ÎªÌ¦Ûq ³]©w«D±`¯S§O¡A³q±`¬O¤£¥Î«ü¬£¨ìScaleModeÄÝ©Ê¡A¦Ó¬O¥H³]©wScaleLeft¡BScaleTop¡BScaleWidth¤ÎScaleHeightÄݩʨөw¸q¦Ûqªº®y¼Ð¨t²Î¡C·í¨Ï¥Î¥L®É¡AScaleModeÄÝ©Ê·|¦Û°Ê¥ÑVisual Basic³]¬°0-¨Ï¥ÎªÌ¦Ûq¡C¦p»Ýn«Ø¥ß¦Ûq®y¼Ð¨Ó²¤ÆÀ³¥Îµ{¦¡ªºµ{¦¡½X¡A¨ÃÅýVisual Basic°õ¦æ©Ò¦³¦ÛqªºÂà´«¡C¥H¤Uªºµ{¦¡·|¦bªí³æ¤W¨Ï¥Î¦Ûq®y¼Ðø¥X¤@Ó¨ç¼Æ¡]¸Ô¨£¹Ï2-14ªºµ²ªG¡^
¡@
¹Ï2-14 ¨Ï¥Î¦Ûq®y¼Ð¨t²Îµe¥X3-D¦h¶µ¦¡¨ç¼Æ¡C |
' X-Y¥±³¡¤À³Q¹º¥X Const XMIN = -5, XMAX = 5, YMIN = -100, YMAX = 100 Const XSTEP = 0.01 Private Sub Form_Resize() ' ³]©w¤@Ó¦Ûqªº®y¼Ðµ¹¥i¨£½d³ò²Å¦X±`¼Æ ScaleLeft = XMIN ScaleTop = YMAX ScaleWidth = XMAX - XMIN ScaleHeight = -(YMAX - YMIN) ' Force a Paint event. Refresh End Sub Private Sub Form_Paint() Dim x As Single, y As Single ' ¶}©lªÅ¥Õªºµe¥¬. Cls ForeColor = vbBlack ' ¶}©lÅã¥Ü»¡©ú CurrentX = ScaleLeft CurrentY = ScaleTop Print "f(x) = x ^ 3 - 2 * x ^ 2 + 10 * x + 5" CurrentX = ScaleLeft Print "X-interval: [" & XMIN & "," & XMAX & "]" CurrentX = ScaleLeft Print "Y-range: [" & YMIN & "," & YMAX & "]" ' µex-¤Îy-¶b Line (XMIN, 0)-(XMAX, 0) Line (0, YMIN)-(0, YMAX) ' µe¥X¼Æ¾Ç¨ç¼Æ ForeColor = vbRed For x = XMIN To XMAX Step XSTEP y = x ^ 3 - 2 * x ^ 2 + 10 * x + 5 PSet (x, y) Next End Sub
½Ð¦h¯d¤ß¤W±µ{¦¡½X¤¤ª`·Nªº¦a¤è¡G
¨Ï¥Î½Õ¦â½L
¡@
º¥ý¨Ó½Í¨Ç²z½×ªºªF¦è¡C¤j³¡¥÷µø°T¥d³£¯àÅã¥Ü1600¸U¦â¡]¤§©Ò¥H»¡¬O²z½×¡A¬O¦]¬°§Ṳ́HÃþ¨ä¹êµLªk¤À¿ë¤j³¡¥÷¬ÛªñªºÃC¦â¡^¡A¦Ó¬Û¹ï¦a¥u¦³¤Ö¼Æ¥þ±m¡]true-color¡^ªºµø°T¥d¬O¥i¦b¿Ã¹õ¤W¬J©wªº¶ZÂ÷¤ºÅã¥Ü³\¦h¦â±mªº¡A¯S§O¬O¦b¸û°ª¸ÑªR«×ªº¿Ã¹õ¤W¡]¬°¤Fn²¤Æ»¡©ú¡A©Ò¥H§Ú²¤¹L±Ôzhigh-color¥d¥i¦P®ÉÅã¥Ü65¡A536¦â¡^¡C¨ä¥Lªº¡AWindows«h¥²»Ý¨Ì¿à½Õ¦â½L¡C
½Õ¦â½L¬O©Ò¦³²z½×¤Wµø°T¥d¤ä´©ªº¦â±m¨ä¤¤ªº256¦â¤§¶°¦X¡C¦pªGµø°T¥d¦b½Õ¦â½L¼Ò¦¡¤¤¥i¹B§@¡A¥L«h»Ýµ¹¿Ã¹õ¤W¨C¤@¹³¯À´£¨Ñ¤@Ӧ줸¡]¦Ó¤£¬O1600¸U¦â©Ò»Ýªº3Ӧ줸¡^¡A¦]¦¹¸`¬Ù¤F«Ü¤jªº°O¾ÐÅéªÅ¶¡¨Ã¼W¶i¤j³¡¥÷¹Ï«¬ªº¹B§@³t«×¡C256¦â¤¤¨C¤@Óȳ£«ü¦V¤@Óµø°T¥d¥i§ä¨ì¨äRGBȪºªí®æ¡C¨C¤@¹³¯À¤]¦³©w¸q¦nªºÃC¦â¡A¤£¹L¦b¿Ã¹õ¤W¦P®É¥X²{ªº¨M¤£·|¶W¹L256¦â¡C
Windows¥»¨Áö«O¯d¤F16ÓÃC¦â¡A¦ý¤´¦³¨Ç¯dµ¹À³¥Îµ{¦¡¨Ï¥Î¡A·í«e´ºÀ³¥Îµ{¦¡nÅã¥Ü¹Ï¹³®É¡A§Y¥i¨Ï¥Î½Õ¦â½L¨Ó§ä¨ì¬Û²Å©ó¹Ï¹³ªºÃC¦â¡C¦ÓY¹Ï¹³©Ò§tªº¦â±m¤j©ó¥i¥ÎªºÃC¦â®É¡AÀ³¥Îµ{¦¡´N±o¥h§ä§é°Jªº¤èªk¡]¨Ò¦p¡G¥Î¬Û¦Pªº½Õ¦â½Lµn¿ý¤GÓ¬Û¦üªº¦â±m¡^¡C¦b¹ê°ÈÀ³¥Î¤W¡A»P¥H¤Uªº°ÝÃD¬Û¸û³o¨ä¹ê¤£¬O¤j°ÝÃD¡G·íÀ³¥Îµ{¦¡¥²»Ý¦b¦P®ÉÅã¥Ü¦hӹϹ³®É¡A¥²µM·|¦b¦U²Õ¤£¦Pªº¦â±m¤¤½Õ©M¡A¦Ó¨º¤@ÓÀu¥ý©O¡H¨º»ò¨ä¥L¹Ï¹³¤S·|«ç¼Ë©O¡H
¤@ª½¨ìVisual Basic 5¡AVisual Basicµ{¦¡¶}µoªÌ¤~ºâ¯u¥¿¦³¸Ñ¨M¤è®×¡AVisual Basic 4¬Æ¦Ü§ó¦ªºª©¥»³£¥uµ¹¦bz-order¤¤ªº²Ä¤@ӹϹ³¦³Àu¥ýÅv¡A¤]´N¬O«ü¦³¾nÂIªºªí³æ©Î±±¨î¶µ¡A¿Ã¹õ¤W¨ä¥L©Ò¦³ªº¹Ï¹³³£¥Î½Õ¦â½L¨ÓÅã¥Ü¡A¦Ó¹ê»Ú¤W«o±`±`»P¨ä¦â±m²Õ¤£¬Û²Å¡Aµ²ªG¤£ºÉ¦p¤H·N¡C±qVisual Basic 5¶}©l¡A²×©ó¦³¤F¥t¤@ºØ¿ï¾Ü¡C
¦¹¤@¥\¯àªºÃöÁä¦b©óªí³æªºPaletteModeÄÝ©Ê¡A¨ä©ó³]p©Î°õ¦æ¶¥¬q¤¤³£¥i³Q«ü¬£¤TºØ¤£¦PªºÈ¡G0-¨t²Î½Õ¦â½L¡B1-³Ì¤W¼h±±¨î¶µªº½Õ¦â½L¡B¤Î2-¦Ûq½Õ¦â½L¡C¨t²Î½Õ¦â½L¬O©T©wªº¡A¥]²[§¹¾ã¡u¼Ð·Çªº¡v¦â±m ¡A¥i´£¨Ñ³\¦h¹Ï¹³¦X©yªº¥ßÅé®ÄªG¡A¦Ó¥B¡AÀ³¥i¤¹³\¥H¤£¦Pªº½Õ¦â½Lªº¦hӹϹ³©M¨ó¦a¥X²{¦bªí³æ¤W¡C¡]¦¹¬°Visual Basic5¤Î6ªí³æªº¹w³]¼Ò¦¡¡^¡C³Ì¤W¼h±±¨î¶µªº½Õ¦â½L¼Ò¦¡¬O¦¹»y¨¥¤§«eª©¥»°ß¤@¥i³]©wªº¼Ò¦¡¡C¦³¾nÂI¤§Form©ÎPictureBox·|¼vÅTµø°T¥d©Ò¨Ï¥Îªº½Õ¦â½L¡A¨ä±N·|¥H¥i¯à³Ì¦nªº¤è¦¡§e²{¡A¦Ó¨ä¥L±±¨î¶µ«h¤£¤@©w¥iµo´§¦¹¯SÂI¡C²Ä¤TºØ³]©w§Y¦Ûq½Õ¦â½L¼Ò¦¡¥i«Ø¥ß¦Ûqªº½Õ¦â½L¡A¥un¦b³]p©Î°õ¦æ¶¥¬q¥ÎLoadPicture¨ç¼Æ«ü¬£¤@ÓÂI°}¹Ïµ¹PaletteÄÝ©Ê´N¥i¥H¤F¡C¦b³oӮרҤ¤¡A»P©Ò´£¨Ñªº¹Ï«¬ÃöÁpªº½Õ¦â½L´NÅܦ¨¦¹ªí³æ©Ò¨Ï¥Îªº½Õ¦â½L¤F¡C
¥H¤W¤¶²Ð¤Fªí³æª«¥ó©Ò¥]¨çªºÄÝ©Ê¡B¤èªk¤Î¨Æ¥ó¡Cª¾¹D¤F³o¨Ç±N¦³§U©ó¤F¸Ñ¤U¤@³¹±N°Q½×ªº©Ò¦³Visual Basic©T¦³ªº±±¨î¶µ¤§¯S©Ê¡C