Date: 07-23-2010
All of the snippets listed on this page are included with
gbSnippets,
a freeware code librarian and
source code editor. You can search
for a snippet using it's gbSnippets gbs number, or simply browse
the
index to find a snippet title of interest.
.Reference API Functions Apps/Dialogs Arrays Assembly Language Callbacks Clipboard Controls - Basic Examples Controls - Techniques Debug Dialogs (built-in) DLLs Edit Controls Files/Folders Graphics .Image Formats BMP Tutor Series (API) GDI Tutor Series (API) GDI+ Tutor Series (API) Screensaver Tutor Series Sprite Tutor Series In Work Internet Keystrokes Math Menus Mouse Multimedia OpenGL Printing RichEdit Control Scintilla SDK SDK - Controls Security Serial Port Sorting Strings System Information Templates (IDE) Threads Time/Timers TreeView Control Edit/Modify Information Traverse/Walk Tree Utilities
created by gbSnippets
API - Short List (Most Useful, with snippets)
API - Longer List (Desc only)
Data Types
Message Structure
MSDN links
Notifications, Messages, Styles (by Common Control)
Notifications, Messages, Styles (by Sys Object)
Pointer Discussion
PowerBASIC Command Syntax
PowerBASIC Keywords
Programmer Tools
Template for IDE+ Option
TextBox Style
Virtual-Key Codes
Window Styles
WM_ Messages (Arguments, Summary, Descriptions)
ChildWindowFromPoint
ClientToScreen
GetCursorPos
GetDlgCtrlID
GetDlgItem
GetFocus
GetModuleHandle/GetModuleFileName/LoadLibrary
GetParent
IsIconic
IsZoomed
LoadLibrary/GetProcAddress
MapWindowPoints
ScreenToClient
SendMessage
SetCursorPos
SetFocus
WindowFromPoint
..X Commands
About Dialog
Allow Single Instance of Application
Cancel Closure (Capture Alt-F4 and "X" Button)
Capture F1
Center on Screen
Create Required Subfolders If Do Not Exist
Create SendTo Shortcut
Display ASCII Table
DragDrop File on Application
Find and Replace
Get Daily Message
Hide a Window
Keep on Top
Limit Min/Max Size
Maintain MRU List
Message Pump - Dialog DoEvents
Minimize/Maximize Programatically
MsgBox$ - Confirmation of Action
MsgBox$ - Modeless
MsgBox$ - Programmatically Close
Online Update #1 - Check For Updates
Online Update #1 - Check for Updates (w/Progress)
Online Update #2 - gbOnlineUpdate.exe
Open Help Files (.chm or .hlp)
Optional DLL
Please Wait ... Dialog
Register Hotkey
Resize Control When Form Resizes
Resource File (Accessing)
Resource File (Create File-Based Resources)
Resource File (Enumerate Items)
Resource File (Files/Text/Number Resources)
Resource File (Get Bitmap Dimensions)
Resource File (Get Bitmap Dimensions) II
Resource File (Get ICON Dimensions)
Resource File (Get String Value)
Resource File (Save Resource to File)
Run DOS Commands
Save/Get Settings using INI file
Scroll Client Area of Dialog
Select Code For Compilation
Set Caption
Set Z-Order
Splitter Bars
Splitter Bars II
Start External App
Test for Minimized/Maximized
.Dimension An Array
.Pass Array to Sub/Function
Check If Array Is Dimensioned
Clear An Array
Cycle Through Array
External App Handle
Fast Array Copy
Insert Specific Element
Join Numeric Array Elements into a Single String
Join String Array Elements into a Single String
Min/Max Value of Array
Randomly Shuffle
Read/Write Array Data to File
Remove Duplicates
Remove Specific Element
Search (Binary)
Search (Scan) Numeric Array
Search (Scan) String Array
Sort Numeric Array
Sort String Array
Convert Binary File to Inline Assembly Statements
Callback Return Values
Callback Skeleton
CB Functions
Control Callback
Custom Message
Lo/Hi Word Extraction
Pointers - Retreiving Structures from Messages
Pointers - Sending Structures with Messages
Copy/Retrieve BMP
Copy/Retrieve Text
. One of Everything
. Syntax Summary
Button
Check3State
CheckBox
ComboBox
Frame
Graphic
Image
ImageX
ImgButton
ImgButtonX
Label
Line
ListBox
ListView
Option
ProgressBar
ScrollBar
StatusBar
TAB
TextBox
Toolbar
TreeView
All Controls - Explode a Control
All Controls - Get/Sect Focus
All Controls - SubClassing
All Controls - Tooltip
Buttons - Programmatically Click
InputBox - Center Over Application
Label - Active URL
Listbox Pair - Fill Right From Left
ListBox Pair - Synchronized Scroll
ListView - Context menu
MsgBox - Center Over Application
MsgBox - Custom Sound/Icon
Multiple TextBox SubClasssing
'OwnerDraw Reference
OwnerDrawn Button
OwnerDrawn Button II
Set TAB Order
TAB - Move TAB Positions
Toolbar - Built-In + User Icons (from files)
Toolbar - Built-In Icons (DDT)
Toolbar - Built-In Icons (SDK)
Toolbar - Dropdown Buttons
Toolbar - Dual TOP Toolbars
Toolbar - Tooltips (DDT)
Toolbar - Tooltips (SDK)
Compiler Directives
Monitor Messages - Callback (GetMsgText)
Monitor Messages - Console Method (WinMsg)
Browse Folders Dialog
Color Dialog
Font Dialog
Open File Dialog
Printer Dialog
Save File Dialog
.Background DLL Information
.Calling Conventions
.Declare Syntax
Create - DLL (LibMain)
Create - DLL (PBLibMain)
Create - Simple DLL
Create - Very Simple DLL
Indirect Calling (Internal Procedure)
RunTime DLL
Use - DLL (LibMain)
Use - DLL (PBLibMain)
Use - Simple DLL
Use - Very Simple DLL
.64K Limit Issues
.Compilable Edit Control Example (Skeleton)
.Edit Control vs RichEdit Control Messages
.Notifications
AutoHighlight Text
Basic 1: Get Text/Boundaries: AllText, Selection, Caret, Current Line, LineM, LinesM-N, CharsM-N
Basic 2: Replace Text: All, Selection, Current Line, LinesM-N, CharM-N
Basic 3: Select Text: All, Current Line, LineM, LinesM-N, CharsM-N
Customize Context menu (Textbox)
Find Text
Flicker Control
Force Case on Text Input
Get Line Count
Get Text of TopMost Visible Line
Remove Highlighting of TextBox on Startup
Save/Restore Position
Set Margin
Set Text Limit
SubClassing
Unselect Text
Backup/Restore a File
Combine Path/File Parts
Confirm Overwrite Of a File
Create Large Empty File
Delete Folder & Sub-Folders
Determine If File Is Open
Determine If File or Folder Exists
Extract Parts of PathName
Get Date/Time of File
Get File Attributes
Get File Size
Get Mode of Open File
Hex Display of String/File
List Drive Letters (DDT only)
List Drive Letters (with type)
List Files/Folders
List Files/Folders (Recursive)
Open DOS at Path
Open Explorer at Path
Open Window at Path
Read Entire Text File Into Array
Read Entire Text File Into String
Read First n Lines of Text File Into Array
Read Text File, One Line At a Time
Read/Write Entire Numeric Array
Send File/Folder to Recycle Bin
.Color Notation
.Graphics Links at MSDN
.Graphics Overview - GDI
.Graphics Overview - GDI+
.Graphics Overview - PowerBASIC
BMP File Format
GIF File Format
JPG File Format
PNG File Format
3D Modelling I - Minimal Code
3D Modelling II - Minimal Code + Read From File
BarCode
.BMP Tutor Reference
BMP Tutor - Read *.bmp (file) --> hBMP (LoadImage)
BMP Tutor - Read *.bmp (resource) --> hBMP (LoadImage)
BMP Tutor - API Copy Image From One Control to Another
BMP Tutor - Read *.bmp (file) --> hDIB (LoadImage)
BMP Tutor - Read *.bmp (file) --> hBMP (Get/Put)
BMP Tutor - Manually Create --> hDIB
BMP Tutor - Create *.bmp by Code
BMP Tutor - Convert bmp$ --> Colors(x,y)
BMP Tutor - Convert Colors(x,y) --> bmp$
BMP Tutor - Ref-01 API/Data Structure Reference
BMP Tutor - Ref-02 Bitmap Types: DIB, DDB, and DIB Section
BMP Tutor - Ref-03 PowerBASIC Bitmap Options: Load/Display/Edit/Save
BMP Tutor - Ref-04 DIB Bitmap File Overview
BMP Tutor - Ref-05 Commonly Used API
BMP Tutor - Ref-06 Padding Calculations
BMP Tutor - Ref-07 Load OEM Bitmaps
BMP Tutor - Ref-08 Load OEM Icons
BMP Tutor - Ref-09 Determine Type of Bitmap
BMP Tutor - Ref-10 Delete/Release DC
BMP Tutor - Ref-11 Extracting Image Color Data
BMP Tutor - Ref-12 Color Arrays and Bistrings
BMP Tutor - Ref-13 Copy DC to DC (BitBlt)
DIB Section
Built-In Icons
Built-In Icons II
Capture Dialog
Capture Screen
Convert Image to DATA Statements
Convert To GrayScale
Copy Image To Clipboard
Display Bitmap
Drawing Shapes (GDI)
GDI Graphic Functions
Bitmaps I
Bitmaps II
Device Context
Filled Shapes / Lines & Curves
Fonts & Text ... empty
GDI vs PowerBASIC
Introduction
Painting and Drawing
Paths/Regions/Clipping ... empty
Pens/Brushes ... empty
Rectangle Math
Introduction
Jose Roca WebSite
Get Bitmap Color Depth (From *.bmp File)
Get Bitmap Dimensions (From *.bmp File)
Get Bitmap Dimensions (Resource Image)
Get Icon Dimensions (Resource Image)
Get Resource Image Size
Get Screen Resolution
Gradient Fill
Graphic Window
Icon - gbSnippets Logo
Load 2 Graphic Controls At One Time
Load Image From File (DDT)
Load Image/ImageX Controls (from .pbr)
Load ImgButton/ImgButtonX Controls (from .pbr)
Load JPG/GIF Images (GDI+)
Load JPG/GIF Images (GDI+) to Graphic Controls
Load JPG/GIF Images (GDI+) to Memory Bitmaps
Load JPG/GIF Images (ListView)
Matrix Waterfall Graphics
Modify Image Using Graphic Get/Set Bits
Mosaic Stereogram
Multi-Thread Write To String
Pixel Manipulation - DIM ... AT
Pixel Manipulation (Bits String)
Pixel Manipulation (show AND/MASK bits)
Plot Data
Print Dialog (Uses clipboard)
Print Dialog (Uses DCs)
Remove Wallpaper
Resize Image - Maintain Aspect Ratio
RGB/BGR/Long Conversions
Save Graphic Target as BMP/GIF/JPG (no input file)
Save Image File as BMP/GIF/JPG
Save Image File as BMP/GIF/JPG (simplified)
Screensaver - Dialog as Canvas
ScreenSaver - Mosaic Stereogram
ScreenSaver - Moving Sprites
ScreenSaver - RFoxDesigns
ScreenSaver - Template (Dialog As Drawing Surface)
ScreenSaver - Template (Uses Graphic Control)
Set Wallpaper - from file
Set Wallpaper - use dialog image
Simulated Line Drawing
SlideShow
Sprite 01 - RealTime, No Buffer, 1 Sprite
Sprite 02 - One Static Image (Bitmap), Single Frame, Memory Bitmap per Frame
Sprite 03 - One Static Image (Icon), Single Frame
Sprite 04 - RealTime Images
Sprite 05 - Array of Static Images (Bitmaps), Single Frame
Sprite 06 - Array of Static Images (Icons), Single Frame
Sprite 07 - Array (1000, 32x32) of Images (Icons) w/Redraw
Sprite 08 - Array (1000, 4x4) of Images (Icons) w/Redraw
Sprite 09 - Array (50Composite, 128x128) of Images (Icons) w/Redraw
Sprite 10 - Array (1000Composite, 32x32) of Images (Icons) w/Redraw
Sprite 101
Sprite 11 - Array (1000Composite, 4x4) of Images (Icons) w/Redraw
Sprite 12 - Dixon (All BASIC)
Sprite 13 - Dixon (All BASIC) - Modified
Sprite 14 - Dixon (w/ASM)
Start Screensaver
Text Stereogram
Associate Extension (Dickinson)
Associate Extension (Navarro)
Associate Extension (Semen)
Associate Extension (Terrier)
Convert hBMP to hIcon (B&W)
Convert hBMP to hIcon (Color)
Convert hBMP to hIcon (Dixon)
Convert hBMP to hIcon (Gary+Paul)
Dialog Units
Explorer Context Menu
Falling Sand
Stock Market Simulator
Syntax Highlighting (Visible Lines Only)
Syntax Highlighting (Visible Lines Only) Test
.Reference: HTTP Message Structures
.Reference: HTTP Request Headers
.Reference: TCP/UDP Statements/Syntax
.Reference: WinInet API & Structures
Create HTML File Programatically
Create URL Shortcut
Email - Send Using Default Client
HTTP Response - Separate Header From Body
HTTP Response - Separate Header Parts
Open URL - Using Default Browser
TCP - Download Header Only
TCP - Download Large File (HTTP)
TCP - Download Small File (HTTP)
TCP - Get URL File Size / Date
URL Parsing
WinInet - Download Header Only
WinInet - Download Large File, w/status
WinInet - Download Small File
WinInet - Get URL File Size / Date
WinInet - PING
WinInet - Test for Internet Connection
%IDOK + %IDCancel + ESC + Enter
%IDOK + Enter (Exception)
.Introduction - Messages & Functions
.Message Detection (TextBox SubClassing)
Ctrl-V
Enter
F1 (Help)
F2
Get Key State At Any Time
Get Key State At Time of Event
TAB
Convert Binary to Decimal
Convert Decimal to Binary
Convert Decimal to Hex
Convert Hex to Decimal
Evaluate Equation
Generate Random Number
Manipulating bits in variables
Round to Specified Decimals
.Really Simple Menu Example
Activate Alt+Accelerator Key
Flip menu check state
Menu - Skeleton, 1-Level
Menu - Skeleton, 2-Level
Menu - Skeleton, Context, TextBox
Show Bitmap In Menu Item
Show Underlines in Menu Text
.Messages of Interest (wParam/lParam definitions)
Detect Mouse Position (All Controls)
Detecting Mouse Wheel Scrolling
Play Sound - MIDI file
Play Sound - WAV file
Play Sound (Resource File)
Play Sound (System Sound)
Play Tones (WinBeep)
Speech Synthesizer (Background Thread)
Speech Synthesizer (Read Text)
All 10 Primitives
Barely Minimal Code
Better Minimal Code (Dialog)
Better Minimal Code (2nd Dialog)
Circle of Line_Loops
Cubes (Points, Wireframe, Solid)
Depth Field
Display List I (1 Cube)
Display List II (2 Cubes)
Display List III (Many Cubes)
glPushMatrix / glPopMatrix
Line, Wide, Antialiasing
Mini-Include
Orthographic vs Perspective Projection
Point, Large, Antialiasing
Rotate Object Around Origin
Sphere (Points, Wireframe, Solid)
Cylinder, Disk, Partial Disk
Template w/User Interface
Template w/User Interface (DoEvents)
Texture Mapping (different image each face)
Texture Mapping (Minimal)
Texture Mapping (same image, all faces)
Twin Viewports (Label Controls)
Two Spinning Cubes, One Orbiting Other
Two Spinning Cubes, Rotate About Common Center
Use Graphic Control As OpenGL Canvas
Use Label Control As OpenGL Canvas
Use Graphic Window As OpenGL Canvas ... in work
Use 2nd Dialog As OpenGL Canvas
WalkThrough (Arrow Keys)
WalkThrough (AutoWalk)
WalkThrough (Mouse)
Wireframe Cube (Line_Loops)
World ... in work
GDIImage Links
Draw text centered on printer page
Line To Line Height
Print Preview
Print Text With Embedded TABs (Multi-Line, Set POS)
Print Text With Embedded TABs (Single Line, Set POS)
Printable Area
Send Page Eject to Printer
Set Printer for 8.5x11 Page
WordWrap
Landscape
.64K Limit Issues
.Compilable RichEdit Example (Skeleton)
.Compilable RichEdit Example (Smaller Skeleton)
.Notifications
.RichEdit vs Edit Control Messages
.Shortcut Keys
.Usage Summary - RichEdit Control
AutoHighlight Text
Basic 1: Get Text/Boundaries: AllText, Selection, Caret, Current Line, LineM, LinesM-N, CharsM-N
Basic 2: Replace Text: All, Selection, Current Line, LineM, LinesM-N, CharsM-N
Basic 3: Select Text: All, Current Line, LineM, LinesM-N, CharsM-N
Character To Left of Cursor
Context menu (RichEdit control)
Ctrl-V Capture via Subclassing
Display Line Numbers/Colors
Enable Hyperlinks
Export To HTML
Export to HTML (w/TAB Expansion)
Flicker Control
Get Bottom Line#
Get Characters m-n
Get Line Count
Get Text of TopMost Visible Line
Get/Save RTF Content
Intellisense
Intellisense w/Syntax Highlighting
Print RTF (Color)
Save/Restore Position
Sequentially Highlight Words (Of Selection)
Set Text Limit
Set Top Line
Setting TabStops
Spell Check (Single Word)
Spell Check (Source Code Strings/Comments)
Spell Check (Using Word Object)
StrikeOut
SubClassing
Synchronized Scroll (2 RichEdit Controls)
Syntax Highlighting
TAB Capture - Subclass (KeyDown)
TAB Capture - Subclass (WM_GetDlgCode)
TAB Capture - WM_NextDlgCtl
Unselect Text
Example00: Introduction
Example01: Minimal Code
Example02: Messages - Controlling Scintilla
Example03: Strings In Messages
Example04: Barely Above Minimal Code
Example05: Template (Shorter)
Example06: Template (Longer)
Example07: Notifications
Example08: Caret Features
Example09: Cursor Shape
Example10: Zoom
Example11: Replace PopupMenu
Example12: Styles
Example13: Display Style Info
Example14: Fonts
Example15: Margins
Example16: Colors
Example17: Find & Replace
Example18: Replace Text Using Targets
Example19: RegExp Find
Example20: Create URL Hotspot
Example21: Greenbar
Example22: Greenbar II
Example23: Greenbar III
Example24: Markers
Example25: Multiple Views
Example26: Indentation Guides
Example27: White Space and End of Line Characters
Example28: Printing
Example29: Keyboard Commands
Example30: Undo/Redo
Example31: Dirty Document Handler
Example32: Cut/Copy/Paste
Example33: Scrolling and AutoScroll
Example34: Count/Position Information
Example35: Selections
Example36: Get/Set Text Actions
Example37: Line Wrapping
Example38: Indicators
Example39: Call Tips
Example40: Brace Highlighting
Example41: AutoCompletion
Example42: Intellisense
Example43: Annotations
Example44: Direct Access (Speed Tip)
Example45: Lexer - Built-In
Example46: Lexer - Container (Simple)
Example47: Lexer - Container (Advanced)
Example48: Lexer - Create External DLL ... on hold
Example49: Lexer - Using External DLL ... on hold
Example50: Folding - Built-In
Example51: Folding - Container (Simple)
Example52: Folding - Container (Advanced)
Reference: LexPB.cxx
Reference: LexVB.cxx
Reference: ScintillaBase.cxx
Reference: PureBasic Custom Lexer
.CreateWindow API Syntax
.PreDefined Class Names
.Summary - DDT vs SDK
.Template for SDK Snippets
.WinMain
Dialog vs Windows
SDK App - 1. Define Class
SDK App - 2. Create/Register Class
SDK App - 3. Show Window
SDK App - 4. Message Loop
SDK App - 5. Message Response
SDK App - 6. Hello World Example
.Background
Button Class - Example
Button Class - Reference
Edit Class - Example
Edit Class - Reference
Static Class - Example
Static Class - Reference
Encrypte/Decrypt a File
.Comm Command Reference
.Tools
Dual Port - Send & Receive
Simple Receive Utility
Simple Send Utility
Numeric Sort
Sort UDT Array
String Sort
Convert Case
Convert TABs to Spaces (DrawTextEx)
Convert TABs to Spaces (GetTextExtentPoint32)
Extract nth Delimited String (Field)
Find nth Occurrence of Substring Within a String
Find SubString Within a String
Fit String To Area (Graphic Control)
Get Physical Length of String
Join Array Elements
Remove Leading/Trailing String/Characters
Replace Multiple Delimiters (with One Delimiter)
Replace Substring Within a String
Sliding String Comparison
Split String Into Array
Text Difference - Markup/Strikeout
Text Differences - Side by Side
Verify String Contains Only Letters/Numbers
Computer Name
Environment variables
Special Folders
User Name
Dialog + Buttons
Dialog + DoEvents Loop
Dialog + Selected Messages
Dialog Only
Simple: Dialog + Button
Simple: Dialog + DoEvents Loop
Simple: Dialog + Selected Messages
Simple: Dialog Only
.Command Summary
.Sleep vs Dialog DoEvents
Custom Thread Messages
Multiple Threads
Simple Thread - One Main, One Secondary
Simple Threads - Two Secondary
Stopping a Thread
Convert MM-DD-YYYY to YYYY-MM-DD
Convert seconds to minutes
Day of Week on Given Date (Method #1)
Day of Week on Given Date (Method #2)
Days Between Two Dates
Synchronization Object
Time - Create a Timer
Time - Elapsed Time Between 2 Events
.Compilable TreeView Example
Cut/Copy/Paste/Delete Nodes (Context Menu)
Delete Children of Node (including sub-nodes)
Delete Node + Children (including sub-nodes)
Edit Tree Label (in-place)
Expand/Collapse Node
Expand/Collapse Node (including sub-nodes)
Save/Restore Tree
Sort Children of Node (no sub-nodes)
Sort Children of Node + SubNodes
Turn Icon Display On/Off
Is Node a Parent
Node Child Count
Node Child Count (including sub-nodes)
Children of Node (return last child)
Children+SubNodes of Node (return last node)
Node to End of Tree (return last node)
One Node Down
Convert gbFind to gbSnippets
File/Folder Browser
File/Folder Browser II
gbDuplicates - Find Duplicate Files
gbFileMerge - Create GBS File From Samples
gbResourceViewer - Resource Image Viewer / Convert to DATA
Placement
Placement II
Read gbSnippets File
Word List
http://www.garybeene.com/sw/gbsnippets.htm