Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Import sources from Camstudio-2.0-src.zip

  • Loading branch information...
commit 6ad8f8c2372f604e4a4be6aeaff39a2d00dc4419 0 parents
@ajasmin authored
Showing with 36,917 additions and 0 deletions.
  1. BIN  vscap20s/ABOUT.BMP
  2. +1,274 −0 vscap20s/AudioFormat.cpp
  3. +70 −0 vscap20s/AudioFormat.h
  4. +54 −0 vscap20s/AudioSpeakers.h
  5. +78 −0 vscap20s/AutoSearchDialog.cpp
  6. +52 −0 vscap20s/AutoSearchDialog.h
  7. +96 −0 vscap20s/AutopanSpeed.cpp
  8. +48 −0 vscap20s/AutopanSpeed.h
  9. +563 −0 vscap20s/CBitmapEx.cpp
  10. +42 −0 vscap20s/CBitmapEx.h
  11. +670 −0 vscap20s/CursorOptionsDlg.cpp
  12. +60 −0 vscap20s/CursorOptionsDlg.h
  13. +481 −0 vscap20s/EditImage.cpp
  14. +67 −0 vscap20s/EditImage.h
  15. +134 −0 vscap20s/EditTransparency.cpp
  16. +56 −0 vscap20s/EditTransparency.h
  17. +410 −0 vscap20s/FixedRegion.cpp
  18. +52 −0 vscap20s/FixedRegion.h
  19. +416 −0 vscap20s/FlashingWnd.cpp
  20. +64 −0 vscap20s/FlashingWnd.h
  21. +165 −0 vscap20s/FolderDialog.cpp
  22. +49 −0 vscap20s/FolderDialog.h
  23. +239 −0 vscap20s/FrameGrabber.cpp
  24. +73 −0 vscap20s/FrameGrabber.h
  25. +839 −0 vscap20s/Keyshortcuts.cpp
  26. +73 −0 vscap20s/Keyshortcuts.h
  27. +104 −0 vscap20s/LayeredWindowHelperST.cpp
  28. +65 −0 vscap20s/LayeredWindowHelperST.h
  29. +103 −0 vscap20s/LayoutList.cpp
  30. +29 −0 vscap20s/LayoutList.h
  31. +24 −0 vscap20s/License.txt
  32. +822 −0 vscap20s/ListManager.cpp
  33. +62 −0 vscap20s/ListManager.h
  34. BIN  vscap20s/Logo.bmp
  35. +136 −0 vscap20s/MULDIV32.H
  36. +378 −0 vscap20s/MainFrm.cpp
  37. +71 −0 vscap20s/MainFrm.h
  38. +58 −0 vscap20s/MciHelpDialog.cpp
  39. +47 −0 vscap20s/MciHelpDialog.h
  40. +325 −0 vscap20s/NewShape.cpp
  41. +50 −0 vscap20s/NewShape.h
  42. +818 −0 vscap20s/Picture.cpp
  43. +43 −0 vscap20s/Picture.h
  44. +115 −0 vscap20s/Player/Player.dsp
  45. +31 −0 vscap20s/Player/Player.plg
  46. +156 −0 vscap20s/Player/Player.rc
  47. +144 −0 vscap20s/Player/Player.vcproj
  48. BIN  vscap20s/Player/appicon1.ico
  49. +482 −0 vscap20s/Player/player.cpp
  50. +13 −0 vscap20s/Player/player.h
  51. BIN  vscap20s/Player/player.ico
  52. +47 −0 vscap20s/Player/player.mak
  53. +25 −0 vscap20s/Player/resource.h
  54. BIN  vscap20s/PlayerPlus/ABOUT.BMP
  55. BIN  vscap20s/PlayerPlus/ABOUTDUBBER.BMP
  56. BIN  vscap20s/PlayerPlus/ABOUTPLAYER.BMP
  57. +15 −0 vscap20s/PlayerPlus/AUDIO.H
  58. +1,084 −0 vscap20s/PlayerPlus/AudioFormat.cpp
  59. +57 −0 vscap20s/PlayerPlus/AudioFormat.h
  60. BIN  vscap20s/PlayerPlus/LOGO.BMP
  61. BIN  vscap20s/PlayerPlus/LOGOPLAYER.BMP
  62. BIN  vscap20s/PlayerPlus/Logodubber.bmp
  63. +136 −0 vscap20s/PlayerPlus/MULDIV32.H
  64. +394 −0 vscap20s/PlayerPlus/MainFrm.cpp
  65. +70 −0 vscap20s/PlayerPlus/MainFrm.h
  66. +108 −0 vscap20s/PlayerPlus/ReadMe.txt
  67. +227 −0 vscap20s/PlayerPlus/SlideToolBar.cpp
  68. +59 −0 vscap20s/PlayerPlus/SlideToolBar.h
  69. +8 −0 vscap20s/PlayerPlus/StdAfx.cpp
  70. +25 −0 vscap20s/PlayerPlus/StdAfx.h
  71. +418 −0 vscap20s/PlayerPlus/audio.cpp
  72. +57 −0 vscap20s/PlayerPlus/fister/Buffer.cpp
  73. +40 −0 vscap20s/PlayerPlus/fister/Buffer.h
  74. +86 −0 vscap20s/PlayerPlus/fister/SoundBase.cpp
  75. +38 −0 vscap20s/PlayerPlus/fister/SoundBase.h
  76. +210 −0 vscap20s/PlayerPlus/fister/SoundFile.cpp
  77. +46 −0 vscap20s/PlayerPlus/fister/SoundFile.h
  78. +228 −0 vscap20s/PlayerPlus/fister/SoundIn.cpp
  79. +48 −0 vscap20s/PlayerPlus/fister/SoundIn.h
  80. +186 −0 vscap20s/PlayerPlus/fister/SoundOut.cpp
  81. +46 −0 vscap20s/PlayerPlus/fister/SoundOut.h
  82. +78 −0 vscap20s/PlayerPlus/playerplus.h
  83. +222 −0 vscap20s/PlayerPlus/playplus.clw
  84. +251 −0 vscap20s/PlayerPlus/playplus.cpp
  85. +232 −0 vscap20s/PlayerPlus/playplus.dsp
  86. +29 −0 vscap20s/PlayerPlus/playplus.dsw
  87. +49 −0 vscap20s/PlayerPlus/playplus.h
  88. BIN  vscap20s/PlayerPlus/playplus.ncb
  89. BIN  vscap20s/PlayerPlus/playplus.opt
  90. +71 −0 vscap20s/PlayerPlus/playplus.plg
  91. +583 −0 vscap20s/PlayerPlus/playplus.rc
  92. +251 −0 vscap20s/PlayerPlus/playplus.vcproj
  93. +84 −0 vscap20s/PlayerPlus/playplusDoc.cpp
  94. +57 −0 vscap20s/PlayerPlus/playplusDoc.h
  95. +4,033 −0 vscap20s/PlayerPlus/playplusView.cpp
  96. +113 −0 vscap20s/PlayerPlus/playplusView.h
  97. BIN  vscap20s/PlayerPlus/res/Thumbs.db
  98. BIN  vscap20s/PlayerPlus/res/Toolbar.bmp
  99. BIN  vscap20s/PlayerPlus/res/playplus.ico
  100. +13 −0 vscap20s/PlayerPlus/res/playplus.rc2
  101. BIN  vscap20s/PlayerPlus/res/playplusDoc.ico
  102. BIN  vscap20s/PlayerPlus/res/toolbar1.bmp
  103. +121 −0 vscap20s/PlayerPlus/resource.h
  104. +95 −0 vscap20s/PresetTime.cpp
  105. +47 −0 vscap20s/PresetTime.h
  106. BIN  vscap20s/Producer/ABOUT.BMP
  107. BIN  vscap20s/Producer/ABOUTDUBBER.BMP
  108. BIN  vscap20s/Producer/ABOUTPLAYER.BMP
  109. +15 −0 vscap20s/Producer/AUDIO.H
  110. +84 −0 vscap20s/Producer/AdvProperty.cpp
  111. +51 −0 vscap20s/Producer/AdvProperty.h
  112. +1,102 −0 vscap20s/Producer/AudioFormat.cpp
  113. +57 −0 vscap20s/Producer/AudioFormat.h
  114. +1,420 −0 vscap20s/Producer/Conversion.cpp
  115. +108 −0 vscap20s/Producer/Conversion.h
  116. +3,021 −0 vscap20s/Producer/Conversion/AAFILE.CPP
  117. +94 −0 vscap20s/Producer/Conversion/DEBUG.H
  118. +362 −0 vscap20s/Producer/Conversion/WAVEIO.CPP
  119. +177 −0 vscap20s/Producer/Conversion/WAVEIO.H
  120. +417 −0 vscap20s/Producer/FlashConversionDlg.cpp
  121. +57 −0 vscap20s/Producer/FlashConversionDlg.h
  122. +220 −0 vscap20s/Producer/FlashInterface.cpp
  123. +53 −0 vscap20s/Producer/FlashInterface.h
  124. BIN  vscap20s/Producer/LOGO.BMP
  125. BIN  vscap20s/Producer/LOGOPLAYER.BMP
  126. BIN  vscap20s/Producer/Logodubber.bmp
  127. +136 −0 vscap20s/Producer/MULDIV32.H
  128. +399 −0 vscap20s/Producer/MainFrm.cpp
  129. +70 −0 vscap20s/Producer/MainFrm.h
  130. +1,127 −0 vscap20s/Producer/MessageWnd.cpp
  131. +138 −0 vscap20s/Producer/MessageWnd.h
  132. +818 −0 vscap20s/Producer/Picture.cpp
  133. +43 −0 vscap20s/Producer/Picture.h
  134. +371 −0 vscap20s/Producer/Producer.clw
  135. +456 −0 vscap20s/Producer/Producer.dsp
  136. +29 −0 vscap20s/Producer/Producer.dsw
  137. +218 −0 vscap20s/Producer/Producer.plg
  138. +867 −0 vscap20s/Producer/Producer.rc
  139. +419 −0 vscap20s/Producer/Producer.vcproj
  140. +210 −0 vscap20s/Producer/ProgressDlg.cpp
  141. +67 −0 vscap20s/Producer/ProgressDlg.h
  142. +108 −0 vscap20s/Producer/ReadMe.txt
  143. +41 −0 vscap20s/Producer/SWFPropertySheet.cpp
  144. +50 −0 vscap20s/Producer/SWFPropertySheet.h
  145. +227 −0 vscap20s/Producer/SlideToolBar.cpp
  146. +59 −0 vscap20s/Producer/SlideToolBar.h
  147. +8 −0 vscap20s/Producer/StdAfx.cpp
  148. +25 −0 vscap20s/Producer/StdAfx.h
  149. +482 −0 vscap20s/Producer/audio.cpp
  150. +57 −0 vscap20s/Producer/fister/Buffer.cpp
  151. +40 −0 vscap20s/Producer/fister/Buffer.h
  152. +86 −0 vscap20s/Producer/fister/SoundBase.cpp
  153. +38 −0 vscap20s/Producer/fister/SoundBase.h
  154. +210 −0 vscap20s/Producer/fister/SoundFile.cpp
  155. +46 −0 vscap20s/Producer/fister/SoundFile.h
  156. +228 −0 vscap20s/Producer/fister/SoundIn.cpp
  157. +48 −0 vscap20s/Producer/fister/SoundIn.h
  158. +186 −0 vscap20s/Producer/fister/SoundOut.cpp
  159. +46 −0 vscap20s/Producer/fister/SoundOut.h
  160. +439 −0 vscap20s/Producer/flashsdk/FDTSounds.cpp
  161. +223 −0 vscap20s/Producer/flashsdk/FDTSounds.h
  162. +56 −0 vscap20s/Producer/flashsdk/FFixed.h
  163. +263 −0 vscap20s/Producer/flashsdk/FSoundSDK.cpp
  164. +137 −0 vscap20s/Producer/flashsdk/FSoundSDK.h
  165. +490 −0 vscap20s/Producer/flashsdk/Macromedia.h
  166. +78 −0 vscap20s/Producer/playerplus.h
  167. +262 −0 vscap20s/Producer/playplus.cpp
  168. +49 −0 vscap20s/Producer/playplus.h
  169. +84 −0 vscap20s/Producer/playplusDoc.cpp
  170. +57 −0 vscap20s/Producer/playplusDoc.h
Sorry, we could not display the entire diff because too many files (501) changed.
BIN  vscap20s/ABOUT.BMP
Binary file not shown
1,274 vscap20s/AudioFormat.cpp
@@ -0,0 +1,1274 @@
+// AudioFormat.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "vscap.h"
+
+#include <mmsystem.h>
+#include <vfw.h>
+#include <windowsx.h>
+
+#include "AudioFormat.h"
+
+#include <stdio.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+// ==========================
+// Ver 1.1
+// ==========================
+
+//External Variables
+extern DWORD waveinselected;
+extern int audio_bits_per_sample;
+extern int audio_num_channels;
+extern int audio_samples_per_seconds;
+extern BOOL bAudioCompression;
+
+extern LPWAVEFORMATEX pwfx;
+extern DWORD cbwfx;
+
+extern UINT AudioDeviceID;
+
+extern BOOL interleaveFrames;
+extern int interleaveFactor;
+extern int interleaveUnit;
+extern void BuildRecordingFormat();
+extern void AllocCompressFormat();
+
+//Local Variables
+LPWAVEFORMATEX pwfxLocal = NULL;
+DWORD cbwfxLocal = 0;
+
+int audio_bits_per_sampleLocal;
+int audio_num_channelsLocal;
+int audio_samples_per_secondsLocal;
+WAVEFORMATEX m_FormatLocal;
+BOOL bAudioCompressionLocal = TRUE;
+
+void AllocLocalCompressFormat();
+void SuggestLocalCompressFormat();
+void BuildLocalRecordingFormat();
+
+
+// Get Textual Description of WAVEFORMAT
+BOOL GetFormatDescription ( LPWAVEFORMATEX pwformat, LPTSTR pszFormatTag, LPTSTR pszFormat) ;
+DWORD formatmap[15];
+int numformat=0;
+
+UINT devicemap[15];
+int numdevice=0;
+
+#define MILLISECONDS 0
+#define FRAMES 1
+
+extern int MessageOut(HWND hWnd,long strMsg, long strTitle, UINT mbstatus);
+
+
+//ver 1.8
+int useMCI = 0;
+extern CString GetProgPath();
+
+
+#if !defined(AVE_FORMAT_MPEGLAYER3)
+#define WAVE_FORMAT_MPEGLAYER3 0x0055
+#endif
+
+
+/////////////////////////////////////////////////////////////////////////////
+// AudioFormat dialog
+
+
+AudioFormat::AudioFormat(CWnd* pParent /*=NULL*/)
+ : CDialog(AudioFormat::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(AudioFormat)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
+}
+
+
+void AudioFormat::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(AudioFormat)
+ // NOTE: the ClassWizard will add DDX and DDV calls here
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(AudioFormat, CDialog)
+ //{{AFX_MSG_MAP(AudioFormat)
+ ON_BN_CLICKED(IDC_CHOOSE, OnChoose)
+ ON_CBN_SELCHANGE(IDC_RECORDFORMAT, OnSelchangeRecordformat)
+ ON_BN_CLICKED(IDC_INTERLEAVE, OnInterleave)
+ ON_BN_CLICKED(IDVOLUME, OnVolume)
+ ON_CBN_SELCHANGE(IDC_INPUTDEVICE, OnSelchangeInputdevice)
+ ON_BN_CLICKED(IDC_INTERLEAVEFRAMES, OnInterleaveframes)
+ ON_BN_CLICKED(IDC_INTERLEAVESECONDS, OnInterleaveseconds)
+ ON_BN_CLICKED(IDC_SYSTEMRECORD, OnSystemrecord)
+ ON_BN_CLICKED(IDC_BUTTON1, OnHelp)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// AudioFormat message handlers
+
+
+void AudioFormat::OnOK()
+{
+
+ CString interleaveFactorStr;
+ int ifactornum;
+
+ ((CEdit *) (GetDlgItem(IDC_IFACTOR)))->GetWindowText(interleaveFactorStr);
+ sscanf(LPCTSTR(interleaveFactorStr),"%d",&ifactornum);
+ if (ifactornum<=0) {
+
+
+ MessageOut(this->m_hWnd,IDS_STRING_INTERLEAVE1, IDS_STRING_NOTE, MB_OK | MB_ICONEXCLAMATION);
+ //MessageBox("Interleave factor must greater than 0","Note",MB_OK | MB_ICONEXCLAMATION);
+ return;
+
+ }
+
+ //if (ifactornum<1000) {
+
+ // MessageBox("Interleave factor must be smaller than 1000","Note",MB_OK | MB_ICONEXCLAMATION);
+ // return;
+
+ //}
+
+ interleaveFactor = ifactornum;
+
+ BOOL binteleave =((CButton *) (GetDlgItem(IDC_INTERLEAVE)))->GetCheck();
+ if (binteleave)
+ interleaveFrames = TRUE;
+ else
+ interleaveFrames = FALSE;
+
+ BOOL interleave_unit= ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->GetCheck();
+ if (interleave_unit)
+ interleaveUnit = FRAMES;
+ else
+ interleaveUnit = MILLISECONDS;
+
+
+ //The Recording format, Compressed format and device must be valid before
+ //data from the Audio Options Dialog can be updated to the external variables
+ if (numformat>0) {
+
+ int sel =((CComboBox *) (GetDlgItem(IDC_COMBO1)))->GetCurSel();
+ if (sel>=0) {
+
+ if (pwfxLocal) {
+
+ //Ver 1.2
+ int getdevice = ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->GetCurSel();
+ if (getdevice < numdevice)
+ {
+
+ if (pwfx == NULL)
+ AllocCompressFormat(); //Allocate external format in order to return values
+
+ if (cbwfx >= cbwfxLocal) { //All checks cleared, update external values
+
+
+ //Updating to external variables
+
+ AudioDeviceID = devicemap[getdevice];
+
+ bAudioCompression = bAudioCompressionLocal;
+
+ //Update the external pwfx (compressed format) ;
+ cbwfx = cbwfxLocal;
+ memcpy( (void *) pwfx, (void *) pwfxLocal, cbwfxLocal );
+
+
+ //Update the external m_Format (Recording format) and related variables;
+ waveinselected = formatmap[sel];
+ audio_bits_per_sample = audio_bits_per_sampleLocal;
+ audio_num_channels = audio_num_channelsLocal;
+ audio_samples_per_seconds = audio_samples_per_secondsLocal;
+
+ BuildRecordingFormat();
+
+ }
+
+
+ }
+
+ }
+
+
+ }
+ }
+
+
+
+ if (pwfxLocal) {
+
+ GlobalFreePtr(pwfxLocal);
+ pwfxLocal = NULL;
+
+ }
+
+ //ver 1.8
+ int val = ((CButton *) (GetDlgItem(IDC_SYSTEMRECORD)))->GetCheck();
+ if (val)
+ useMCI = 1;
+ else
+ useMCI = 0;
+
+ CDialog::OnOK();
+}
+
+
+BOOL AudioFormat::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ // TODO: Add extra initialization here
+
+ //Interleave
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVE)))->SetCheck(interleaveFrames);
+ CString interleaveFactorStr;
+ interleaveFactorStr.Format("%d",interleaveFactor);
+ ((CEdit *) (GetDlgItem(IDC_IFACTOR)))->SetWindowText(interleaveFactorStr);
+
+ if (interleaveFrames) {
+ ((CButton *) (GetDlgItem(IDC_IFACTOR)))->EnableWindow(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->EnableWindow(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->EnableWindow(TRUE);
+
+ }
+ else {
+ ((CButton *) (GetDlgItem(IDC_IFACTOR)))->EnableWindow(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->EnableWindow(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->EnableWindow(FALSE);
+
+ }
+
+
+ if (interleaveUnit == FRAMES) {
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->SetCheck(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->SetCheck(FALSE);
+ }
+ else {
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->SetCheck(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->SetCheck(TRUE);
+ }
+
+
+ audio_bits_per_sampleLocal = audio_bits_per_sample;
+ audio_num_channelsLocal = audio_num_channels;
+ audio_samples_per_secondsLocal = audio_samples_per_seconds;
+
+ bAudioCompressionLocal = bAudioCompression;
+
+
+ //Ver 1.2
+
+ //Generate device list
+ numdevice = 0;
+ devicemap[numdevice] = WAVE_MAPPER;
+ numdevice ++ ;
+
+ ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->ResetContent( );
+ ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->AddString("Default input device");
+
+ int numdevs=waveInGetNumDevs();
+ for (int i=0; i<numdevs; i++)
+ {
+ WAVEINCAPS wicaps;
+ MMRESULT mmr=waveInGetDevCaps(i,&wicaps,sizeof(WAVEINCAPS));
+ if (mmr==MMSYSERR_NOERROR)
+ {
+
+ ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->AddString(wicaps.szPname);
+ devicemap[numdevice] = i;
+ numdevice ++ ;
+
+ }
+
+ }
+
+ //Select the device combo box
+ int deviceIsSelected= 0;
+ int selectedDevice = WAVE_MAPPER;
+ for (i=0; i<numdevice; i++) {
+
+ if (AudioDeviceID == devicemap[i]) {
+ ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->SetCurSel(i);
+ selectedDevice = devicemap[i];
+ deviceIsSelected = 1;
+ }
+
+ }
+ if (!deviceIsSelected) {
+ if (numdevice)
+ ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->SetCurSel(0);
+
+ }
+
+
+ //Ver 1.2
+ WAVEINCAPS pwic;
+ MMRESULT mmr = waveInGetDevCaps( AudioDeviceID , &pwic, sizeof(pwic) );
+
+ int selected_cindex=-1; //selected index of combo box
+ numformat=0; //counter, number of format
+
+
+ //This code works on the assumption (when filling in values for the user - interfaces)
+ //that the m_Format and pwfx formats (external variables) are already chosen correctly and compatibile with each other
+ int devID;
+ devID = ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->GetCurSel();
+ if (devID < numdevice) {
+
+ UpdateDeviceData(selectedDevice,waveinselected,pwfx);
+
+ }
+
+ //ver 1.8
+ ((CButton *) (GetDlgItem(IDC_SYSTEMRECORD)))->SetCheck(useMCI);
+
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+
+void AudioFormat::OnChoose()
+{
+ // TODO: Add your control notification handler code here
+ ACMFORMATCHOOSE acmfc;
+ MMRESULT mmresult;
+
+ if (pwfxLocal==NULL)
+ SuggestLocalCompressFormat();
+
+ //
+ // initialize the ACMFORMATCHOOSE members
+ //
+ memset(&acmfc, 0, sizeof(acmfc));
+
+ acmfc.cbStruct = sizeof(acmfc);
+ acmfc.hwndOwner = m_hWnd;
+ acmfc.pwfx = pwfxLocal;
+
+
+ //if (initial_audiosetup)
+ // acmfc.fdwStyle = 0;
+ //else
+ acmfc.fdwStyle = ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
+
+ acmfc.cbwfx = cbwfxLocal;
+ acmfc.pszTitle = TEXT("Audio Compression Format");
+ acmfc.szFormatTag[0] = '\0';
+ acmfc.szFormat[0] = '\0';
+ acmfc.pszName = NULL;
+ acmfc.cchName = 0;
+ acmfc.fdwEnum = 0;
+ acmfc.pwfxEnum = NULL;
+ acmfc.hInstance = NULL;
+ acmfc.pszTemplateName = NULL;
+ acmfc.lCustData = 0L;
+ acmfc.pfnHook = NULL;
+
+ /////////////////////////////
+ // Valid formats for saving
+ /////////////////////////////
+ BuildLocalRecordingFormat();
+
+ acmfc.pwfxEnum = &m_FormatLocal;
+ acmfc.fdwEnum = ACM_FORMATENUMF_SUGGEST ;
+
+ //
+ //
+ //
+ mmresult = acmFormatChoose(&acmfc);
+ if (MMSYSERR_NOERROR != mmresult)
+ {
+ if (ACMERR_CANCELED != mmresult)
+ {
+
+ CString msgstr;
+ CString tstr;
+ tstr.LoadString(IDS_STRING_NOTE);
+ msgstr.Format("FormatChoose() failed with error = %u!", mmresult);
+ MessageBox(msgstr,tstr, MB_OK | MB_ICONEXCLAMATION);
+
+ }
+
+ return ;
+ }
+
+
+ TRACE("\nWAVEFORMAT:");
+ TRACE("\nwFormatTag = %d",pwfxLocal->wFormatTag);
+ TRACE("\nnChannels = %d",pwfxLocal->nChannels);
+ TRACE("\nnSamplesPerSec = %d",pwfxLocal->nSamplesPerSec);
+ TRACE("\nnAvgBytesPerSec = %d",pwfxLocal->nAvgBytesPerSec);
+ TRACE("\nnBlockAlign = %d",pwfxLocal->nBlockAlign);
+ TRACE("\ncbSize = %d",pwfxLocal->cbSize);
+
+
+ UpdateLocalCompressFormatInterface();
+
+
+
+}
+
+
+void AudioFormat::UpdateLocalCompressFormatInterface() {
+
+
+ if (bAudioCompressionLocal==0) {
+
+ ((CEdit *) (GetDlgItem(IDC_COMPRESSEDFORMATTAG)))->SetWindowText("None Available");
+ ((CEdit *) (GetDlgItem(IDC_COMPRESSEDFORMAT)))->SetWindowText(" ");
+ return;
+
+ }
+
+ char pszFormat[200];
+ char pszFormatTag[200];
+ BOOL res = GetFormatDescription ( pwfxLocal, pszFormatTag, pszFormat);
+
+ if (res) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMPRESSEDFORMATTAG)))->SetWindowText(pszFormatTag);
+ ((CComboBox *) (GetDlgItem(IDC_COMPRESSEDFORMAT)))->SetWindowText(pszFormat);
+
+ }
+
+}
+
+BOOL GetFormatDescription ( LPWAVEFORMATEX pwformat, LPTSTR pszFormatTag, LPTSTR pszFormat)
+{
+ MMRESULT mmr;
+
+ // Retrieve the descriptive name for the FormatTag in pwformat.
+ if (NULL != pszFormatTag) {
+ ACMFORMATTAGDETAILS aftd;
+
+
+ memset(&aftd, 0, sizeof(aftd));
+
+ // Fill in the required members FormatTAG query.
+ aftd.cbStruct = sizeof(aftd);
+ aftd.dwFormatTag = pwformat->wFormatTag;
+
+
+ // Ask ACM to find first available driver that supports the specified Format tag.
+ mmr = acmFormatTagDetails(NULL, &aftd,
+ ACM_FORMATTAGDETAILSF_FORMATTAG);
+ if (MMSYSERR_NOERROR != mmr) {
+
+ return (FALSE);
+ }
+
+ // Copy the Format tag name into the calling application's
+ // buffer.
+ lstrcpy(pszFormatTag, aftd.szFormatTag);
+ }
+
+ CString formatstr;
+ CString str_samples_per_second;
+ CString str_bits_per_sample;
+ CString str_avg_bytes_per_second;
+ CString str_nchannels;
+
+ str_samples_per_second.Format("%d Hz",pwformat->nSamplesPerSec);
+ str_bits_per_sample.Format("%d Bit",pwformat->wBitsPerSample);
+ str_avg_bytes_per_second.Format("%d Bytes/sec",pwformat->nAvgBytesPerSec);
+ if (pwformat->nChannels==1)
+ str_nchannels.Format("Mono");
+ else
+ str_nchannels.Format("Stereo");
+
+ formatstr = str_samples_per_second + ", ";
+ if ((pwformat->wBitsPerSample)>0) formatstr = formatstr + str_bits_per_sample + ", ";
+ formatstr = formatstr + str_nchannels + " " + str_avg_bytes_per_second;
+ lstrcpy(pszFormat, LPCTSTR(formatstr));
+
+
+ return (TRUE);
+}
+
+
+
+void AudioFormat::OnSelchangeRecordformat()
+{
+
+ if (numformat<=0)
+ return; //no format to choose from
+
+ int sel =((CComboBox *) (GetDlgItem(IDC_COMBO1)))->GetCurSel();
+ if (sel<0) return;
+
+
+ if (formatmap[sel] == WAVE_FORMAT_1M08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 11025;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_1M16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 11025;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_1S08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 11025;
+
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_1S16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 11025;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_2M08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 22050;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_2M16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 22050;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_2S08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 22050;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_2S16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 22050;
+
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_4M08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 44100;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_4M16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 1;
+ audio_samples_per_secondsLocal = 44100;
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_4S08) {
+
+ audio_bits_per_sampleLocal = 8;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 44100;
+
+
+ }
+
+ if (formatmap[sel] == WAVE_FORMAT_4S16) {
+
+ audio_bits_per_sampleLocal = 16;
+ audio_num_channelsLocal = 2;
+ audio_samples_per_secondsLocal = 44100;
+
+
+ }
+
+ BuildLocalRecordingFormat();
+ SuggestLocalCompressFormat();
+ UpdateLocalCompressFormatInterface();
+
+
+}
+
+void AudioFormat::OnInterleave()
+{
+ // TODO: Add your control notification handler code here
+ BOOL binteleave =((CButton *) (GetDlgItem(IDC_INTERLEAVE)))->GetCheck();
+ if (binteleave) {
+
+ ((CButton *) (GetDlgItem(IDC_IFACTOR)))->EnableWindow(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->EnableWindow(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->EnableWindow(TRUE);
+
+ }
+ else {
+
+ ((CButton *) (GetDlgItem(IDC_IFACTOR)))->EnableWindow(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->EnableWindow(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->EnableWindow(FALSE);
+
+ }
+
+}
+
+
+void BuildLocalRecordingFormat() {
+
+ m_FormatLocal.wFormatTag = WAVE_FORMAT_PCM;
+ m_FormatLocal.wBitsPerSample = audio_bits_per_sampleLocal;
+ m_FormatLocal.nSamplesPerSec = audio_samples_per_secondsLocal;
+ m_FormatLocal.nChannels = audio_num_channelsLocal;
+ m_FormatLocal.nBlockAlign = m_FormatLocal.nChannels * (m_FormatLocal.wBitsPerSample/8);
+ m_FormatLocal.nAvgBytesPerSec = m_FormatLocal.nSamplesPerSec * m_FormatLocal.nBlockAlign;
+ m_FormatLocal.cbSize = 0;
+
+}
+
+
+void SuggestLocalCompressFormat() {
+
+ bAudioCompressionLocal = TRUE;
+
+ AllocLocalCompressFormat();
+
+ //1st try MPEGLAYER3
+ BuildLocalRecordingFormat();
+ MMRESULT mmr;
+ if ((m_FormatLocal.nSamplesPerSec == 22050) && (m_FormatLocal.nChannels==2) && (m_FormatLocal.wBitsPerSample <= 16)) {
+
+ pwfxLocal->wFormatTag = WAVE_FORMAT_MPEGLAYER3;
+ mmr = acmFormatSuggest(NULL, &m_FormatLocal, pwfxLocal, cbwfxLocal, ACM_FORMATSUGGESTF_WFORMATTAG);
+
+ }
+
+ if (mmr!=0) {
+
+ //ver 1.6, use PCM if MP3 not available
+
+ //Then try ADPCM
+ //BuildLocalRecordingFormat();
+ //pwfxLocal->wFormatTag = WAVE_FORMAT_ADPCM;
+ //MMRESULT mmr = acmFormatSuggest(NULL, &m_FormatLocal, pwfxLocal, cbwfxLocal, ACM_FORMATSUGGESTF_WFORMATTAG);
+
+
+ if (mmr!=0) {
+
+ //Use the PCM as default
+ BuildLocalRecordingFormat();
+ pwfxLocal->wFormatTag = WAVE_FORMAT_PCM;
+ MMRESULT mmr = acmFormatSuggest(NULL, &m_FormatLocal, pwfxLocal, cbwfxLocal, ACM_FORMATSUGGESTF_WFORMATTAG);
+
+
+ if (mmr!=0) {
+
+ bAudioCompressionLocal = FALSE;
+
+
+ }
+
+
+ }
+
+ }
+
+}
+
+
+void AllocLocalCompressFormat() {
+
+
+ if (pwfxLocal) {
+
+ //Do nothing....already allocated
+
+ }
+ else {
+
+ MMRESULT mmresult = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &cbwfxLocal);
+ if (MMSYSERR_NOERROR != mmresult)
+ {
+
+ CString msgstr;
+ CString tstr;
+ tstr.LoadString(IDS_STRING_NOTE);
+ msgstr.Format("Metrics failed mmresult=%u!", mmresult);
+ ::MessageBox(NULL,msgstr,tstr, MB_OK | MB_ICONEXCLAMATION);
+ return ;
+ }
+
+ if (cbwfxLocal < cbwfx) cbwfxLocal = cbwfx;
+
+
+ pwfxLocal = (LPWAVEFORMATEX)GlobalAllocPtr(GHND, cbwfxLocal);
+ if (NULL == pwfxLocal)
+ {
+
+ CString msgstr;
+ CString tstr;
+ tstr.LoadString(IDS_STRING_NOTE);
+ msgstr.Format("GlobalAllocPtr(%lu) failed!", cbwfxLocal);
+ ::MessageBox(NULL,msgstr,tstr, MB_OK | MB_ICONEXCLAMATION);
+ return ;
+ }
+
+
+ }
+
+}
+
+
+
+void AudioFormat::OnCancel()
+{
+ // TODO: Add extra cleanup here
+ if (pwfxLocal) {
+
+ GlobalFreePtr(pwfxLocal);
+ pwfxLocal = NULL;
+
+ }
+
+ CDialog::OnCancel();
+}
+
+void AudioFormat::OnVolume()
+{
+ // Ver 1.1
+ if (waveInGetNumDevs() == 0) {
+
+ //CString msgstr;
+ //msgstr.Format("Unable to detect audio input device. You need a sound card with microphone input.");
+ //MessageBox(msgstr,"Note", MB_OK | MB_ICONEXCLAMATION);
+ MessageOut(this->m_hWnd,IDS_STRING_NOINPUT1 ,IDS_STRING_NOTE,MB_OK | MB_ICONEXCLAMATION);
+
+ return;
+
+ }
+
+ CString launchPath("");
+ CString testLaunchPath;
+ CString exeFileName("\\sndvol32.exe");
+
+ char dirx[300];
+ GetWindowsDirectory(dirx,300);
+ CString Windir(dirx);
+ CString AppDir;
+ CString SubDir;
+
+
+ //Test Windows\sndvol32.exe
+ AppDir = Windir;
+ SubDir = "";
+ testLaunchPath=AppDir+SubDir+exeFileName;
+ if (launchPath=="") {
+
+ //Verify sndvol32.exe exists
+ OFSTRUCT ofs;
+ HFILE hdir = OpenFile(testLaunchPath, &ofs,OF_EXIST);
+ if (hdir != HFILE_ERROR) {
+
+ launchPath=testLaunchPath;
+
+ }
+
+ }
+
+ //Test Windows\system32\sndvol32.exe
+ AppDir = Windir;
+ SubDir = "\\system32";
+ testLaunchPath=AppDir+SubDir+exeFileName;
+ if (launchPath=="") {
+
+ //Verify sndvol32.exe exists
+ OFSTRUCT ofs;
+ HFILE hdir = OpenFile(testLaunchPath, &ofs,OF_EXIST);
+ if (hdir != HFILE_ERROR) {
+
+ launchPath=testLaunchPath;
+
+ //need CloseHandle ?
+ //BOOL ret = CloseHandle((HANDLE) hdir);
+ //if (!ret) MessageBox("Close handle Fails","Note",MB_OK | MB_ICONEXCLAMATION);
+
+ }
+
+ }
+
+
+ //Test Windows\system\sndvol32.exe
+ AppDir = Windir;
+ SubDir = "\\system32";
+ testLaunchPath=AppDir+SubDir+exeFileName;
+ if (launchPath=="") {
+
+ //Verify sndvol32.exe exists
+ OFSTRUCT ofs;
+ HFILE hdir = OpenFile(testLaunchPath, &ofs,OF_EXIST);
+ if (hdir != HFILE_ERROR) {
+
+ launchPath=testLaunchPath;
+
+ }
+
+ }
+
+
+ if (launchPath!="") { //launch Volume Control
+
+ //not sure
+ launchPath = launchPath + " /r /rec /record";
+
+ if (WinExec(launchPath,SW_SHOW)!=0) {
+
+
+ }
+ else {
+ //MessageBox("Error launching Volume Control!","Note",MB_OK | MB_ICONEXCLAMATION);
+ MessageOut(this->m_hWnd,IDS_STRING_ERRVOLCTRL1 ,IDS_STRING_NOTE,MB_OK | MB_ICONEXCLAMATION);
+
+ }
+
+ }
+
+}
+
+void AudioFormat::OnSelchangeInputdevice()
+{
+ // TODO: Add your control notification handler code here
+
+
+ int devID;
+ devID = ((CComboBox *) (GetDlgItem(IDC_INPUTDEVICE)))->GetCurSel();
+ if (devID < numdevice) {
+
+ UpdateDeviceData(devicemap[devID],waveinselected,NULL);
+
+ }
+
+}
+
+
+// ver 1.2
+// =====================================
+// UpdateDeviceData
+//
+// Update the user - interface based on the device data
+//
+// If the third parameter (compressed format) is not null, we assume it is compatibile with the 2nd parameter (recording format)
+//
+// =====================================
+void AudioFormat::UpdateDeviceData(UINT deviceID, DWORD curr_sel_rec_format, LPWAVEFORMATEX curr_sel_pwfx) {
+
+
+ WAVEINCAPS pwic;
+ MMRESULT mmr = waveInGetDevCaps( deviceID , &pwic, sizeof(pwic) );
+
+ int selected_cindex=-1; //selected index of combo box
+ numformat=0; //counter, number of format
+
+
+ //Reset Recording Format Combo Box and format map
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->ResetContent();
+ numformat = 0;
+
+
+ //This code works on the assumption (when filling in values for the interfaces)
+ //that the m_Format and pwfx formats (external variables) are already chosen correctly and compatibile with each other
+ if ((pwic.dwFormats) & WAVE_FORMAT_1M08) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("11.025 kHz, mono, 8-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_1M08;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_1M16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("11.025 kHz, mono, 16-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_1M16;
+ numformat++;
+
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_1S08) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("11.025 kHz, stereo, 8-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_1S08;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_1S16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("11.025 kHz, stereo, 16-bit");
+
+ formatmap[numformat]=WAVE_FORMAT_1S16;
+ numformat++;
+
+
+ }
+
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_2M08) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("22.05 kHz, mono, 8-bit");
+
+ formatmap[numformat]=WAVE_FORMAT_2M08;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_2M16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("22.05 kHz, mono, 16-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_2M16;
+ numformat++;
+
+ }
+
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_2S08) {
+
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("22.05 kHz, stereo, 8-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_2S08;
+ numformat++;
+
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_2S16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("22.05 kHz, stereo, 16-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_2S16;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_4M08) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("44.1 kHz, mono, 8-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_4M08;
+ numformat++;
+
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_4M16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("44.1 kHz, mono, 16-bit");
+
+
+ formatmap[numformat]=WAVE_FORMAT_4M16;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_4S08) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("44.1 kHz, stereo, 8-bit");
+
+ formatmap[numformat]=WAVE_FORMAT_4S08;
+ numformat++;
+
+ }
+
+ if ((pwic.dwFormats) & WAVE_FORMAT_4S16) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("44.1 kHz, stereo, 16-bit");
+
+ formatmap[numformat]=WAVE_FORMAT_4S16;
+ numformat++;
+
+ }
+
+
+ if (numformat<=0) {
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->AddString("None Available");
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->SetCurSel(0);
+
+
+ ((CEdit *) (GetDlgItem(IDC_COMPRESSEDFORMATTAG)))->SetWindowText("None Available");
+ ((CEdit *) (GetDlgItem(IDC_COMPRESSEDFORMAT)))->SetWindowText(" ");
+
+ ((CButton *) (GetDlgItem(IDC_CHOOSE)))->EnableWindow(FALSE);
+
+ //For this case, where no recording format, compressed format is available
+ //is handled by OnOk (no external formats is updated) when the user press the OK button.
+ return;
+
+ }
+ else {
+
+ ((CButton *) (GetDlgItem(IDC_CHOOSE)))->EnableWindow(TRUE);
+
+ }
+
+
+ for (int k=0;k<numformat;k++) {
+
+ if (curr_sel_rec_format == formatmap[k])
+ selected_cindex=k;
+
+ }
+
+
+ //If can reach here ==> numformat > 0
+ if ((selected_cindex==-1) && (numformat>0)) { //selected recording format not found
+
+ //force selection to one that is compatible
+ selected_cindex=0;
+
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->SetCurSel(selected_cindex);
+
+ //force selection of compress format
+ OnSelchangeRecordformat() ;
+
+
+ }
+ else {
+
+ //Compressed or Save format
+ AllocLocalCompressFormat();
+ if (curr_sel_pwfx==NULL) {
+
+ SuggestLocalCompressFormat();
+ }
+ else {
+ memcpy( (void *) pwfxLocal, (void *) curr_sel_pwfx, cbwfx );
+
+ }
+
+ UpdateLocalCompressFormatInterface();
+
+ //will this following line call OnSelchangeRecordformat() ?
+ if (selected_cindex>=0)
+ ((CComboBox *) (GetDlgItem(IDC_COMBO1)))->SetCurSel(selected_cindex);
+
+
+ }
+
+}
+
+void AudioFormat::OnInterleaveframes()
+{
+ // TODO: Add your control notification handler code here
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->SetCheck(TRUE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->SetCheck(FALSE);
+
+}
+
+void AudioFormat::OnInterleaveseconds()
+{
+ // TODO: Add your control notification handler code here
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVEFRAMES)))->SetCheck(FALSE);
+ ((CButton *) (GetDlgItem(IDC_INTERLEAVESECONDS)))->SetCheck(TRUE);
+
+}
+
+void AudioFormat::OnSystemrecord()
+{
+ // TODO: Add your control notification handler code here
+
+
+}
+
+void AudioFormat::OnHelp()
+{
+ // TODO: Add your control notification handler code here
+ CString progdir,helppath;
+ progdir=GetProgPath();
+ helppath= progdir + "\\help.htm#Helpmci";
+
+ Openlink(helppath);
+
+
+}
+
+
+BOOL AudioFormat::Openlink (CString link)
+{
+
+ BOOL bSuccess = FALSE;
+
+ //As a last resort try ShellExecuting the URL, may
+ //even work on Navigator!
+ if (!bSuccess)
+ bSuccess = OpenUsingShellExecute (link);
+
+ if (!bSuccess)
+ bSuccess = OpenUsingRegisteredClass (link);
+ return bSuccess;
+}
+
+
+BOOL AudioFormat::OpenUsingShellExecute (CString link)
+{
+ LPCTSTR mode;
+ mode = _T ("open");
+
+ //HINSTANCE hRun = ShellExecute (GetParent ()->GetSafeHwnd (), mode, m_sActualLink, NULL, NULL, SW_SHOW);
+ HINSTANCE hRun = ShellExecute (GetSafeHwnd (), mode, link, NULL, NULL, SW_SHOW);
+ if ((int) hRun <= HINSTANCE_ERROR)
+ {
+ TRACE ("Failed to invoke URL using ShellExecute\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+BOOL AudioFormat::OpenUsingRegisteredClass (CString link)
+{
+ TCHAR key[MAX_PATH + MAX_PATH];
+ HINSTANCE result;
+
+ if (GetRegKey (HKEY_CLASSES_ROOT, _T (".htm"), key) == ERROR_SUCCESS)
+ {
+ LPCTSTR mode;
+ mode = _T ("\\shell\\open\\command");
+ _tcscat (key, mode);
+ if (GetRegKey (HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS)
+ {
+ LPTSTR pos;
+ pos = _tcsstr (key, _T ("\"%1\""));
+ if (pos == NULL)
+ { // No quotes found
+
+ pos = strstr (key, _T ("%1")); // Check for %1, without quotes
+
+ if (pos == NULL) // No parameter at all...
+
+ pos = key + _tcslen (key) - 1;
+ else
+ *pos = _T ('\0'); // Remove the parameter
+
+ }
+ else
+ *pos = _T ('\0'); // Remove the parameter
+
+ _tcscat (pos, _T (" "));
+ _tcscat (pos, link);
+ result = (HINSTANCE) WinExec (key, SW_SHOW);
+ if ((int) result <= HINSTANCE_ERROR)
+ {
+ CString str;
+ switch ((int) result)
+ {
+ case 0:
+ str = _T ("The operating system is out\nof memory or resources.");
+ break;
+ case SE_ERR_PNF:
+ str = _T ("The specified path was not found.");
+ break;
+ case SE_ERR_FNF:
+ str = _T ("The specified file was not found.");
+ break;
+ case ERROR_BAD_FORMAT:
+ str = _T ("The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image).");
+ break;
+ case SE_ERR_ACCESSDENIED:
+ str = _T ("The operating system denied\naccess to the specified file.");
+ break;
+ case SE_ERR_ASSOCINCOMPLETE:
+ str = _T ("The filename association is\nincomplete or invalid.");
+ break;
+ case SE_ERR_DDEBUSY:
+ str = _T ("The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed.");
+ break;
+ case SE_ERR_DDEFAIL:
+ str = _T ("The DDE transaction failed.");
+ break;
+ case SE_ERR_DDETIMEOUT:
+ str = _T ("The DDE transaction could not\nbe completed because the request timed out.");
+ break;
+ case SE_ERR_DLLNOTFOUND:
+ str = _T ("The specified dynamic-link library was not found.");
+ break;
+ case SE_ERR_NOASSOC:
+ str = _T ("There is no application associated\nwith the given filename extension.");
+ break;
+ case SE_ERR_OOM:
+ str = _T ("There was not enough memory to complete the operation.");
+ break;
+ case SE_ERR_SHARE:
+ str = _T ("A sharing violation occurred.");
+ break;
+ default:
+ str.Format (_T ("Unknown Error (%d) occurred."), (int) result);
+ }
+ str = _T ("Unable to open hyperlink:\n\n") + str;
+ AfxMessageBox (str, MB_ICONEXCLAMATION | MB_OK);
+ }
+ else
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+
+LONG AudioFormat::GetRegKey (HKEY key, LPCTSTR subkey, LPTSTR retdata)
+{
+ HKEY hkey;
+ LONG retval = RegOpenKeyEx (key, subkey, 0, KEY_QUERY_VALUE, &hkey);
+
+ if (retval == ERROR_SUCCESS)
+ {
+ long datasize = MAX_PATH;
+ TCHAR data[MAX_PATH];
+ RegQueryValue (hkey, NULL, data, &datasize);
+ _tcscpy (retdata, data);
+ RegCloseKey (hkey);
+ }
+
+ return retval;
+}
+
70 vscap20s/AudioFormat.h
@@ -0,0 +1,70 @@
+#if !defined(AFX_AUDIOFORMAT_H__D1098020_67C5_491D_AC06_2EE69A7C135D__INCLUDED_)
+#define AFX_AUDIOFORMAT_H__D1098020_67C5_491D_AC06_2EE69A7C135D__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AudioFormat.h : header file
+//
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// AudioFormat dialog
+
+class AudioFormat : public CDialog
+{
+// Construction
+public:
+ AudioFormat(CWnd* pParent = NULL); // standard constructor
+ void UpdateLocalCompressFormatInterface();
+ void UpdateDeviceData(UINT deviceID, DWORD curr_sel_rec_format, LPWAVEFORMATEX curr_sel_pwfx);
+
+ BOOL Openlink (CString);
+ BOOL OpenUsingShellExecute (CString);
+ LONG GetRegKey (HKEY key, LPCTSTR subkey, LPTSTR retdata);
+ BOOL OpenUsingRegisteredClass (CString);
+
+
+ //CVscapView *myparent;
+ //void PreModal(CVscapView *myparent);
+
+// Dialog Data
+ //{{AFX_DATA(AudioFormat)
+ enum { IDD = IDD_AUDIODIALOG };
+ // NOTE: the ClassWizard will add data members here
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(AudioFormat)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(AudioFormat)
+ virtual void OnOK();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnChoose();
+ afx_msg void OnSelchangeRecordformat();
+ afx_msg void OnInterleave();
+ virtual void OnCancel();
+ afx_msg void OnVolume();
+ afx_msg void OnSelchangeInputdevice();
+ afx_msg void OnInterleaveframes();
+ afx_msg void OnInterleaveseconds();
+ afx_msg void OnSystemrecord();
+ afx_msg void OnHelp();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_AUDIOFORMAT_H__D1098020_67C5_491D_AC06_2EE69A7C135D__INCLUDED_)
54 vscap20s/AudioSpeakers.h
@@ -0,0 +1,54 @@
+#if !defined(AFX_AUDIOSPEAKERS_H__125948FB_55C2_4D8E_8E21_36B3AE266E28__INCLUDED_)
+#define AFX_AUDIOSPEAKERS_H__125948FB_55C2_4D8E_8E21_36B3AE266E28__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AudioSpeakers.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// AudioSpeakers dialog
+
+class AudioSpeakers : public CDialog
+{
+// Construction
+public:
+ AudioSpeakers(CWnd* pParent = NULL); // standard constructor
+ void OnUpdateLineConfig(int line_proper);
+ void OnUpdateVolume();
+
+// Dialog Data
+ //{{AFX_DATA(AudioSpeakers)
+ enum { IDD = IDD_AUDIOWAVEOUT };
+ // NOTE: the ClassWizard will add data members here
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(AudioSpeakers)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(AudioSpeakers)
+ virtual void OnOK();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnVolume();
+ afx_msg void OnAutoconfig();
+ afx_msg void OnSelchangeSounddevice();
+ afx_msg void OnManualconfig();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_AUDIOSPEAKERS_H__125948FB_55C2_4D8E_8E21_36B3AE266E28__INCLUDED_)
78 vscap20s/AutoSearchDialog.cpp
@@ -0,0 +1,78 @@
+// AutoSearchDialog.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "vscap.h"
+#include "AutoSearchDialog.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutoSearchDialog dialog
+
+
+CAutoSearchDialog::CAutoSearchDialog(CWnd* pParent /*=NULL*/)
+ : CDialog(CAutoSearchDialog::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CAutoSearchDialog)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
+}
+
+
+void CAutoSearchDialog::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAutoSearchDialog)
+ // NOTE: the ClassWizard will add DDX and DDV calls here
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CAutoSearchDialog, CDialog)
+ //{{AFX_MSG_MAP(CAutoSearchDialog)
+ ON_BN_CLICKED(IDC_CLOSE, OnCloseDialog)
+ ON_WM_CLOSE()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutoSearchDialog message handlers
+
+void CAutoSearchDialog::SetVarText(CString textstr)
+{
+ ((CStatic *) GetDlgItem(IDC_TEXT1))->SetWindowText(textstr);
+
+}
+
+void CAutoSearchDialog::SetVarTextLine2(CString textstr)
+{
+ ((CStatic *) GetDlgItem(IDC_TEXT2))->SetWindowText(textstr);
+
+}
+
+void CAutoSearchDialog::SetButtonEnable(BOOL enable)
+{
+ ((CStatic *) GetDlgItem(IDC_CLOSE))->EnableWindow(enable);
+
+}
+
+
+void CAutoSearchDialog::OnCloseDialog()
+{
+ // TODO: Add your control notification handler code here
+ ShowWindow(SW_HIDE);
+
+}
+
+void CAutoSearchDialog::OnClose()
+{
+ // TODO: Add your message handler code here and/or call default
+ ShowWindow(SW_HIDE);
+
+ //CDialog::OnClose();
+}
52 vscap20s/AutoSearchDialog.h
@@ -0,0 +1,52 @@
+#if !defined(AFX_AUTOSEARCHDIALOG_H__CAEFF236_0E36_49BC_8B1A_0F2D903EDE9D__INCLUDED_)
+#define AFX_AUTOSEARCHDIALOG_H__CAEFF236_0E36_49BC_8B1A_0F2D903EDE9D__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// AutoSearchDialog.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutoSearchDialog dialog
+
+class CAutoSearchDialog : public CDialog
+{
+// Construction
+public:
+ CAutoSearchDialog(CWnd* pParent = NULL); // standard constructor
+ void SetVarText(CString textstr);
+ void SetVarTextLine2(CString textstr);
+ void SetButtonEnable(BOOL enable);
+
+
+// Dialog Data
+ //{{AFX_DATA(CAutoSearchDialog)
+ enum { IDD = IDD_AUTOSEARCH };
+ // NOTE: the ClassWizard will add data members here
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAutoSearchDialog)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(CAutoSearchDialog)
+ afx_msg void OnCloseDialog();
+ afx_msg void OnClose();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_AUTOSEARCHDIALOG_H__CAEFF236_0E36_49BC_8B1A_0F2D903EDE9D__INCLUDED_)
+
96 vscap20s/AutopanSpeed.cpp
@@ -0,0 +1,96 @@
+// RenderSoft CamStudio
+//
+// Copyright 2001 RenderSoft Software & Web Publishing
+//
+//
+// AutopanSpeed.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "vscap.h"
+#include "AutopanSpeed.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+extern int maxpan;
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutopanSpeed dialog
+
+
+CAutopanSpeed::CAutopanSpeed(CWnd* pParent /*=NULL*/)
+ : CDialog(CAutopanSpeed::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CAutopanSpeed)
+ // NOTE: the ClassWizard will add member initialization here
+ //}}AFX_DATA_INIT
+}
+
+
+void CAutopanSpeed::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAutopanSpeed)
+ // NOTE: the ClassWizard will add DDX and DDV calls here
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CAutopanSpeed, CDialog)
+ //{{AFX_MSG_MAP(CAutopanSpeed)
+ ON_WM_HSCROLL()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutopanSpeed message handlers
+
+BOOL CAutopanSpeed::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ // TODO: Add extra initialization here
+ CString maxpanspeedstr;
+
+ ((CSliderCtrl *) GetDlgItem(IDC_PANSLIDER))->SetRange(1,200,TRUE);
+ ((CSliderCtrl *) GetDlgItem(IDC_PANSLIDER))->SetPos(maxpan);
+
+ maxpanspeedstr.Format("%d",maxpan);
+ ((CStatic *) GetDlgItem(IDC_MAXSPEED))->SetWindowText(maxpanspeedstr);
+
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CAutopanSpeed::OnOK()
+{
+ // TODO: Add extra validation here
+ int maxpanspeed;
+ CString maxpanspeedstr;
+
+ ((CStatic *) GetDlgItem(IDC_MAXSPEED))->GetWindowText(maxpanspeedstr);
+ sscanf(LPCTSTR(maxpanspeedstr),"%d",&maxpanspeed);
+
+ maxpan = maxpanspeed;
+
+ CDialog::OnOK();
+}
+
+void CAutopanSpeed::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
+{
+ // TODO: Add your message handler code here and/or call default
+ int maxpanspeed;
+ CString maxpanspeedstr;
+
+ maxpanspeed = ((CSliderCtrl *) GetDlgItem(IDC_PANSLIDER))->GetPos();
+ maxpanspeedstr.Format("%d",maxpanspeed);
+ ((CStatic *) GetDlgItem(IDC_MAXSPEED))->SetWindowText(maxpanspeedstr);
+
+
+ CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
+}
48 vscap20s/AutopanSpeed.h
@@ -0,0 +1,48 @@
+#if !defined(AFX_AUTOPANSPEED_H__49D4B2FA_02DF_4EAC_BA42_F2EEDEA2FE58__INCLUDED_)
+#define AFX_AUTOPANSPEED_H__49D4B2FA_02DF_4EAC_BA42_F2EEDEA2FE58__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+// AutopanSpeed.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CAutopanSpeed dialog
+
+class CAutopanSpeed : public CDialog
+{
+// Construction
+public:
+ CAutopanSpeed(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CAutopanSpeed)
+ enum { IDD = IDD_AUTOPANSPEED };
+ // NOTE: the ClassWizard will add data members here
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAutopanSpeed)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(CAutopanSpeed)
+ virtual void OnOK();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_AUTOPANSPEED_H__49D4B2FA_02DF_4EAC_BA42_F2EEDEA2FE58__INCLUDED_)
563 vscap20s/CBitmapEx.cpp
@@ -0,0 +1,563 @@
+// CBITMAPEX.CPP
+// CBitmap extention
+//
+// (c) Vadim Gorbatenko, 1997-99
+// gvv@mail.tomsknet.ru
+// All rights reserved
+//
+//___________________________________________________________________________________________
+
+#include "stdafx.h"
+#include "CBitmapEx.h"
+
+#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
+#define PALETTESIZE(lpbi) (_DIBNumColors((LPBITMAPINFOHEADER) lpbi)* sizeof (RGBQUAD))
+#define DIBCOLORS(lpbi) ((LPRGBQUAD)((LPBYTE)(lpbi) + (int)(lpbi)->biSize))
+#define DIBPTR(lpbi) (LPBYTE)(DIBCOLORS((LPBITMAPINFOHEADER)lpbi) + (UINT)((LPBITMAPINFOHEADER)lpbi)->biClrUsed)
+
+HANDLE _dibFromBitmap(HBITMAP hBitmap);
+BOOL _writeDib(HANDLE hdib, LPCSTR filename);
+INT _DIBNumColors (LPBITMAPINFOHEADER lpbi);
+
+
+CBitmapEx::CBitmapEx():CBitmap()
+{
+ _modBMP= NULL;
+
+}
+
+
+CBitmapEx::~CBitmapEx()
+{
+ EndModify();//just in case:)
+}
+
+HANDLE CBitmapEx::DibFromBitmap()
+ {return _dibFromBitmap((HBITMAP)GetSafeHandle());}
+
+HANDLE CBitmapEx::DibFromBitmap(HBITMAP hb)
+ {return _dibFromBitmap(hb);}
+
+BOOL CBitmapEx::CreateFromDib(LPBITMAPINFO lpBi)
+{
+ if(!lpBi || _modBMP) return FALSE;
+ if(((LPBITMAPINFOHEADER)lpBi)->biCompression != BI_RGB)
+ return FALSE;
+
+ if(GetSafeHandle( ))
+ {
+
+ //check existing size
+ BITMAP bmp;
+ GetObject(sizeof BITMAP, &bmp);
+ CSize sz = GetSize();
+
+ if(bmp.bmWidth == ((LPBITMAPINFOHEADER)lpBi)->biWidth &&
+ bmp.bmHeight == ((LPBITMAPINFOHEADER)lpBi)->biHeight)
+ {
+ // special case: we don't need to destroy existing
+ // DDB, just rewrite bits.
+ // Note: we must be sure, the color resolution is
+ // not changed, so, let's test it:
+ HDC hdc = ::GetDC(NULL);
+ int hdc_bits = GetDeviceCaps(hdc,BITSPIXEL);
+ if(hdc_bits == bmp.bmBitsPixel)
+ {
+ //ok to set new bits
+ BOOL ret = ::SetDIBits(
+ hdc, // handle to device context
+ (HBITMAP)GetSafeHandle( ), // handle to bitmap
+ 0, // starting scan line
+ bmp.bmHeight, // number of scan lines
+ DIBPTR(lpBi), // array of bitmap bits
+ lpBi, // address of structure with bitmap data
+ DIB_RGB_COLORS // type of color indexes to use
+ ) == bmp.bmHeight;
+
+ ::ReleaseDC(NULL,hdc);
+ return ret;
+ }
+ else
+ ::ReleaseDC(NULL,hdc);
+ }
+ //delete existing bitmap:(
+ DeleteObject();
+ }
+ //create a new DDB
+ HDC hdc;
+ HBITMAP hbm;
+
+ //Create DDB
+ hdc = ::GetDC(NULL);
+ hbm = CreateDIBitmap(hdc, (LPBITMAPINFOHEADER)lpBi,(LONG)CBM_INIT,
+ DIBPTR(lpBi), lpBi, DIB_RGB_COLORS );
+
+ ::ReleaseDC(NULL,hdc);
+ if(!hbm) return FALSE;
+
+ DeleteObject();//delete attached bitmap
+
+ if(!Attach( (HGDIOBJ) hbm ))
+ {::DeleteObject((HGDIOBJ)hbm); return FALSE;}
+
+ return TRUE;
+
+}
+
+#define sfiltr "Image files (*.BMP)|*.BMP||"
+#define sext "BMP"
+#define smask NULL
+
+BOOL CBitmapEx::Open(LPCSTR filename, LPCSTR DialogTitle)
+{
+
+ if(GetSafeHandle( ))
+ return FALSE;
+ CString Path;
+
+ if(!filename)
+ {
+ CFileDialog openAs( TRUE,sext,
+ smask, OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|
+ OFN_PATHMUSTEXIST,
+ sfiltr);
+
+ //substitude dialog title
+ if(DialogTitle)
+ openAs.m_ofn.lpstrTitle=DialogTitle;
+
+ if(openAs.DoModal()==IDOK)
+
+ Path=openAs.GetPathName( );
+
+ else return FALSE;
+ }
+ else Path= filename;
+
+ CFile file;
+
+ if(!file.Open(Path,CFile::modeRead|CFile::typeBinary))
+ return FALSE;
+
+ BITMAPFILEHEADER bmfHeader;
+ LPBITMAPINFOHEADER lpbi;
+ DWORD dwBitsSize;
+ //ULONGLONG dwBitsSize;
+ HANDLE hDIB;
+
+
+ // get length of DIB in bytes for use when reading
+ dwBitsSize = file.GetLength();
+
+ BOOL ret=TRUE;
+ TRY
+ {
+
+ if( file.Read(&bmfHeader, sizeof (BITMAPFILEHEADER))!=
+ sizeof (BITMAPFILEHEADER)||
+ bmfHeader.bfType!=((WORD) ('M' << 8) | 'B')) ret=FALSE;
+
+ }
+ CATCH (CFileException, e)
+ {
+ ret=FALSE;
+
+ }
+ END_CATCH
+
+ if(!ret) return FALSE;
+
+ // Allocate memory for DIB
+ dwBitsSize -= sizeof(BITMAPFILEHEADER);
+
+ hDIB = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, dwBitsSize);
+
+ if(!hDIB) return FALSE;
+
+ lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+ TRY
+ {
+ //if(file.ReadHuge((LPVOID)lpbi, dwBitsSize)!=dwBitsSize)
+ if(file.Read((LPVOID)lpbi, dwBitsSize)!=dwBitsSize)
+ ret=FALSE;
+ }
+ CATCH (CFileException, e)
+ {
+ ret=FALSE;
+
+ }
+ END_CATCH
+ file.Close();
+
+
+ if(!ret)
+ {GlobalUnlock (hDIB); GlobalFree (hDIB); return FALSE;}
+
+
+
+ HDC hdc;
+ HBITMAP hbm;
+
+ //Create DDB
+ hdc = ::GetDC(NULL);
+ hbm = CreateDIBitmap(hdc,(LPBITMAPINFOHEADER)lpbi,(LONG)CBM_INIT,
+ DIBPTR(lpbi),(LPBITMAPINFO)lpbi,DIB_RGB_COLORS );
+
+ ::ReleaseDC(NULL,hdc);
+
+ GlobalUnlock (hDIB);
+ GlobalFree (hDIB);
+
+ if(!hbm)
+ {return FALSE;}
+
+ if(GetSafeHandle( ))
+ DeleteObject();
+
+ if(!Attach( (HGDIOBJ) hbm ))
+ {::DeleteObject((HGDIOBJ)hbm); return FALSE;}
+
+
+ return ret;
+}
+
+BOOL CBitmapEx::Save(LPCSTR filename, LPCSTR DialogTitle)
+{
+
+ if(!GetSafeHandle( ))
+ return FALSE;
+ CString Path;
+
+ if(!filename)
+ {
+
+ CFileDialog saveAs( FALSE,sext,
+ smask, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
+ sfiltr);
+
+ if(DialogTitle)
+ saveAs.m_ofn.lpstrTitle=DialogTitle;
+
+ if(saveAs.DoModal()==IDOK)
+ Path=saveAs.GetPathName( );
+
+ else return FALSE;
+ }
+ else Path=filename;
+
+ CFile file;
+
+ if(!file.Open((LPCSTR)Path,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary))
+ return FALSE;
+
+ HANDLE hdib=_dibFromBitmap((HBITMAP)GetSafeHandle( ));
+
+ if(!hdib) return FALSE;
+
+ BITMAPFILEHEADER hdr;
+ LPBITMAPINFOHEADER lpbi;
+
+ lpbi = (LPBITMAPINFOHEADER)GlobalLock (hdib);
+
+ // Fill in the fields of the file header
+ hdr.bfType = ((WORD) ('M' << 8) | 'B'); // "BM"
+ hdr.bfSize = GlobalSize (hdib) + sizeof (BITMAPFILEHEADER);
+ hdr.bfReserved1 = 0;
+ hdr.bfReserved2 = 0;
+ hdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + lpbi->biSize +
+ PALETTESIZE((LPSTR)lpbi);
+
+ BOOL ret=TRUE;
+ TRY
+ {
+ file.Write((LPSTR)&hdr, sizeof (BITMAPFILEHEADER));
+ //file.WriteHuge((LPSTR)lpbi, GlobalSize (hdib));
+ file.Write((LPSTR)lpbi, GlobalSize (hdib));
+ }
+ CATCH (CFileException, e)
+ {
+ ret=FALSE;
+
+ }
+ END_CATCH
+
+ file.Close();
+ GlobalUnlock (hdib);
+ GlobalFree (hdib);
+
+ return ret;
+}
+
+
+// Get DC for "in-memory" drawing
+CDC *CBitmapEx::BegingModify()
+{
+ CWnd* dtw= CWnd::GetDesktopWindow( );
+ CDC *dc=dtw->GetDC();
+
+ if(_modDC.m_hDC)
+ _modDC.DeleteDC( );
+
+ _modDC.CreateCompatibleDC(dc);
+
+ _modBMP = _modDC.SelectObject(this);
+
+ dtw->ReleaseDC(dc);
+ return &_modDC;
+
+}
+// Create color bitmap
+BOOL CBitmapEx::CreateColor(int dx, int dy)
+{
+ if(GetSafeHandle()) return FALSE;
+ HDC hScrDC = ::GetDC(NULL);
+ HDC hMemDC = ::CreateCompatibleDC(hScrDC);
+
+ BOOL r = CreateCompatibleBitmap(CDC::FromHandle(hScrDC), dx, dy);
+
+ ::DeleteDC(hMemDC);
+ ::ReleaseDC(NULL,hScrDC);
+ return r;
+}
+
+// Create monocolor bitmap
+BOOL CBitmapEx::CreateMono(int dx, int dy)
+{
+ if(GetSafeHandle()) return FALSE;
+ CDC mDC;
+ mDC.CreateCompatibleDC(NULL); //for mono!
+
+ BOOL r = CreateCompatibleBitmap( &mDC, dx, dy );
+
+ mDC.DeleteDC( );
+ return r;
+}
+
+// This was the first extention i've done! :)))
+CSize CBitmapEx::GetSize()
+{
+ BITMAP bmp;
+ if(!GetSafeHandle()) return CSize(0,0);
+ GetObject(sizeof BITMAP, &bmp);
+ return CSize(bmp.bmWidth,bmp.bmHeight);
+}
+
+void CBitmapEx::BitBlt(CDC *dc_to, POINT at, DWORD rop)
+{
+ CSize sz=GetSize();
+
+ dc_to->BitBlt(at.x,at.y, sz.cx, sz.cy,
+ BegingModify(),//source context
+ 0,0, rop);
+ EndModify();
+}
+
+void CBitmapEx::StretchBlt(CDC *dc_to, CRect to, DWORD rop)
+{
+ CSize sz=GetSize();
+ dc_to->StretchBlt(to.left, to.top,
+ to.Width(), to.Height(),
+ BegingModify(),//source context
+ 0,0,
+ sz.cx, sz.cy,
+ rop);
+ EndModify();
+}
+
+void CBitmapEx::EndModify()
+{
+ if(_modDC.m_hDC && _modBMP)
+ _modDC.SelectObject(_modBMP);
+ if(_modDC.m_hDC)
+ _modDC.DeleteDC( );
+ _modBMP = NULL;
+}
+
+//Copy the other bitmap to this
+BOOL CBitmapEx::CopyRect(CBitmap& bmp, CRect& rc)
+{
+
+ CWnd* dtw= CWnd::GetDesktopWindow( );
+ CDC *dc=dtw->GetDC();
+
+
+ CDC cdc;
+ CDC cdc2;
+
+ cdc2.CreateCompatibleDC(dc);
+ cdc.CreateCompatibleDC(dc);
+
+ bmp.CreateCompatibleBitmap( dc, rc.Width(), rc.Height());
+
+ CBitmap *ob2=cdc2.SelectObject(&bmp);
+
+ CBitmap *ob=cdc.SelectObject(this);
+
+ cdc2.BitBlt( 0, 0, rc.Width(), rc.Height(),
+ &cdc, rc.left, rc.top, SRCCOPY );
+
+ cdc2.SelectObject(ob2);
+
+ cdc.SelectObject(ob);
+
+ dtw->ReleaseDC(dc);
+ return TRUE;
+}
+
+DWORD CBitmapEx::DibImageSize(HANDLE hDIB)
+{
+ if(!hDIB) return 0;
+ LPBITMAPINFOHEADER lpbmInfoHdr=(LPBITMAPINFOHEADER) GlobalLock (hDIB);
+ DWORD sz=sizeof (BITMAPINFOHEADER)+PALETTESIZE ((LPSTR) lpbmInfoHdr) + lpbmInfoHdr->biSizeImage;
+ GlobalUnlock(hDIB);
+ return sz;
+}
+
+/////////////////////////////////////////////////
+// DDB->DIB
+HANDLE _dibFromBitmap(HBITMAP hBitmap)
+{
+ HDC hDC;
+ WORD wBits;
+ HPALETTE hPal=NULL;
+ BITMAP bm;
+ BITMAPINFOHEADER bi;
+ BITMAPINFOHEADER *lpbi;
+ DWORD dwLen;
+ HANDLE hDIB;
+
+ if (!hBitmap)
+ return NULL;
+
+ ::GetObject (hBitmap, sizeof (bm), (LPSTR)&bm);
+
+ wBits = bm.bmBitsPixel;
+
+ bi.biSize = sizeof (BITMAPINFOHEADER);
+ bi.biWidth = bm.bmWidth;
+ bi.biHeight = bm.bmHeight;
+ bi.biPlanes = 1;
+ bi.biBitCount = wBits;
+ bi.biCompression = BI_RGB;
+ bi.biSizeImage = 0;
+ bi.biXPelsPerMeter = 0;
+ bi.biYPelsPerMeter = 0;
+ bi.biClrUsed = 0;
+ bi.biClrImportant = 0;
+
+ dwLen = bi.biSize + PALETTESIZE ((LPSTR) &bi);
+ hDIB = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE,dwLen);
+
+ if (!hDIB)
+ return NULL;
+
+ lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+ *lpbi = bi;
+
+ HWND hWnd= GetFocus();
+
+ if(!hWnd)
+ {//load default system palette
+ hPal = (HPALETTE)GetStockObject (DEFAULT_PALETTE);
+ hDC = GetDC (NULL);
+ hPal = SelectPalette (hDC, hPal, FALSE);
+ RealizePalette(hDC);
+ }
+ else
+ {
+ //or get palette from focused window
+ HDC hDCw = GetDC (hWnd);
+ hPal = SelectPalette (hDCw, (HPALETTE)GetStockObject (DEFAULT_PALETTE), FALSE);
+ hDC = GetDC (NULL);
+ hPal = SelectPalette (hDC, hPal, FALSE);
+ RealizePalette(hDC);
+ SelectPalette (hDCw, hPal, FALSE);
+ ReleaseDC(hWnd,hDCw);
+ }
+
+ // calculate the biSizeImage
+ GetDIBits (hDC,
+ hBitmap,
+ 0,
+ (WORD) bi.biHeight,
+ NULL,
+ (LPBITMAPINFO) lpbi,
+ DIB_RGB_COLORS);
+
+ bi = *lpbi;
+ GlobalUnlock(hDIB);
+
+ // If the driver did not fill in the biSizeImage field,
+ // make one up
+
+ if (bi.biSizeImage == 0)
+ {
+ bi.biSizeImage = WIDTHBYTES((DWORD)bm.bmWidth * wBits) * bm.bmHeight;
+
+ if (bi.biCompression != BI_RGB)
+ bi.biSizeImage = (bi.biSizeImage * 3) / 2;
+ }
+
+
+ DWORD sl =dwLen;
+ HGLOBAL hPtr =hDIB;
+ dwLen = bi.biSize + PALETTESIZE((LPSTR)&bi) + bi.biSizeImage;
+
+ // if you have plans to use DDE or clipboard, you have
+ // to allocate memory with GMEM_DDESHARE flag
+ if(!(hDIB = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE,dwLen)))
+ {
+ SelectPalette(hDC,hPal,FALSE);
+ ReleaseDC(NULL,hDC);
+ GlobalFree(hPtr);
+ return NULL;}
+
+ lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
+ LPBITMAPINFOHEADER lpS=(LPBITMAPINFOHEADER)GlobalLock(hPtr);
+
+ CopyMemory(lpbi,lpS,sl);
+ GlobalUnlock(hPtr);
+ GlobalFree(hPtr);
+
+
+ // actually fill lpBits
+ if (GetDIBits( hDC,
+ hBitmap,
+ 0,
+ (WORD) bi.biHeight,
+ (LPSTR) lpbi + (WORD) lpbi->biSize + PALETTESIZE((LPSTR) lpbi),
+ (LPBITMAPINFO) lpbi, DIB_RGB_COLORS) == 0)
+ {
+ GlobalUnlock (hDIB);
+ hDIB = NULL;
+ SelectPalette (hDC, hPal, FALSE);
+ ReleaseDC (NULL, hDC);
+ return NULL;
+ }
+
+ bi = *lpbi;
+ GlobalUnlock (hDIB);
+ SelectPalette (hDC, hPal, FALSE);
+ ReleaseDC (NULL, hDC);
+ //OK
+ return hDIB;
+}
+
+
+
+int _DIBNumColors (LPBITMAPINFOHEADER lpbi)
+{
+ if (lpbi->biClrUsed)
+ return (int)lpbi->biClrUsed;
+ switch (lpbi->biBitCount)
+ {
+ case 1:
+ return 2;
+ case 4:
+ return 16;
+ case 8:
+ return 256;
+ default:
+ return 0; //16,24,32 bits bitmap has no color table
+ }
+}
42 vscap20s/CBitmapEx.h
@@ -0,0 +1,42 @@
+// CBITMAPEX.H
+// CBitmap extention
+//
+//
+//___________________________________________________________________________________________
+
+#ifndef _CBITMAPEX_INCL
+#define _CBITMAPEX_INCL
+
+class CBitmapEx : public CBitmap
+{
+public:
+ CBitmapEx();
+ ~CBitmapEx();
+ //load&save DDB
+ BOOL Open(LPCSTR filename, LPCSTR DialogTitle=NULL);
+ BOOL Save(LPCSTR filename, LPCSTR DialogTitle=NULL);
+
+ void BitBlt(CDC *dc_to, POINT at, DWORD rop=SRCCOPY);
+ void StretchBlt(CDC *dc_to, CRect to, DWORD rop=SRCCOPY);
+ CSize GetSize();
+
+ BOOL CreateMono(int dx, int dy);
+ BOOL CreateColor(int dx, int dy);
+ BOOL CreateFromDib(LPBITMAPINFO lpBi);
+
+
+ BOOL CopyRect(CBitmap& bmp, CRect& rc);
+ HANDLE DibFromBitmap();
+
+ CDC *BegingModify();
+ void EndModify();
+
+static HANDLE DibFromBitmap(HBITMAP);
+static DWORD DibImageSize(HANDLE hDIB);
+
+protected:
+ CDC _modDC;
+ CBitmap *_modBMP;
+};
+
+#endif //_RBITMAP_INCL
670 vscap20s/CursorOptionsDlg.cpp
@@ -0,0 +1,670 @@
+// RenderSoft CamStudio
+//
+// Copyright 2001 RenderSoft Software & Web Publishing
+//
+//
+// CursorOptionsDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "vscap.h"
+//#include <stdio.h>
+#include "CursorOptionsDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+//Internal Vars..should put into class header
+CFileDialog *iconFileDlg;
+HCURSOR previewcursor = NULL;
+HCURSOR loadcursor;
+HCURSOR customcursor;
+int customsel;
+int recordcursor;
+int cursortype;
+int highlightcursor;
+int highlightsize;
+int highlightshape;
+COLORREF highlightcolor;
+int initpaint=TRUE;
+
+
+//extern CFileDialog *iconFileDlg;
+extern HCURSOR g_loadcursor;
+extern HCURSOR g_customcursor;
+extern int g_customsel;
+extern int g_recordcursor;
+extern int g_cursortype;
+extern int g_highlightcursor;
+extern int g_highlightsize;
+extern int g_highlightshape;
+extern COLORREF g_highlightcolor;
+extern CString cursordir;
+extern CString g_cursorFilePath;