Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Debug Error On
#Debug Display On
%Unicode = 1
#Include "Win32API.inc"
#Include Once "dshow.inc"
#Include Once "dshow_utilities.inc"
%IDM_Get = 500
%IDM_Set1920 = 501
%IDM_Set1600 = 502
%IDM_Set1280 = 503
%IDM_Set640 = 504
%IDM_Sep = 505
Function PBMain() As Long
Dialog New Pixels, 0, "Set Specified Format",,,640,480, %WS_OverlappedWindow Or %WS_ClipChildren To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x,y,w,h,fBits As Long
Select Case Cb.Msg
Case %WM_InitDialog
FormatIndex = 10 'in my camera, #10 is 1920x1080x24
CreateContextMenu
DisplayFirstCamera
SetCurrentFormat 'uses FormatIndex to get w/h/bits. see WM_Command below
GetCurrentFormat(w,h,fBits)
Dialog Set Text hDlg, "Get Current Format: " + Str$(w) + Str$(h) + " " + Time$
Case %WM_Command
Select Case Cb.Ctl
Case %IDM_Get : GetCurrentFormat(w,h,fBits) : SetDialogCaption(w,h,fBits)
Case %IDM_Set1920 : FormatIndex=10 : SetCurrentFormat : DisplayFirstCamera : GetCurrentFormat(w,h,fBits) : SetDialogCaption(w,h,fBits)
Case %IDM_Set1600 : FormatIndex=8 : SetCurrentFormat : DisplayFirstCamera : GetCurrentFormat(w,h,fBits) : SetDialogCaption(w,h,fBits)
Case %IDM_Set1280 : FormatIndex=6 : SetCurrentFormat : DisplayFirstCamera : GetCurrentFormat(w,h,fBits) : SetDialogCaption(w,h,fBits)
Case %IDM_Set640 : FormatIndex=0 : SetCurrentFormat : DisplayFirstCamera : GetCurrentFormat(w,h,fBits) : SetDialogCaption(w,h,fBits)
End Select
Case %WM_ContextMenu
x = Lo(Integer,Cb.LParam) : y = Hi(Integer, Cb.LParam)
TrackPopupMenu hContext, %TPM_LeftAlign, x, y, 0, Cb.Hndl, ByVal 0
End Select
End Function
Sub CreateContextMenu
Menu New PopUp To hContext
Menu Add String, hContext, "Get", %IDM_Get, %MF_Enabled
Menu Add String, hContext, "-", %IDM_Sep, %MF_Enabled
Menu Add String, hContext, "1920x1080", %IDM_Set1920, %MF_Enabled
Menu Add String, hContext, "1600x1200", %IDM_Set1600, %MF_Enabled
Menu Add String, hContext, "1280x720", %IDM_Set1280, %MF_Enabled
Menu Add String, hContext, "640x480", %IDM_Set640, %MF_Enabled
End Sub
http://www.garybeene.com/sw/gbsnippets.htm