Click here to Skip to main content
15,918,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how the tcp server retrieve the clients which connected to it? (help..help...help..) Pin
**bamboo**17-May-04 22:34
**bamboo**17-May-04 22:34 
GeneralRe: how the tcp server retrieve the clients which connected to it? (help..help...help..) Pin
Prakash Nadar17-May-04 23:00
Prakash Nadar17-May-04 23:00 
QuestionHow to select a folder in vc++(MFC) Pin
shiva shankar17-May-04 21:45
shiva shankar17-May-04 21:45 
AnswerRe: How to select a folder in vc++(MFC) Pin
Prakash Nadar17-May-04 21:50
Prakash Nadar17-May-04 21:50 
GeneralChat Server Pin
Rassul Yunussov17-May-04 21:32
Rassul Yunussov17-May-04 21:32 
GeneralThumbnail View Pin
chakk17-May-04 21:28
chakk17-May-04 21:28 
GeneralRe: Thumbnail View Pin
alex.barylski17-May-04 21:38
alex.barylski17-May-04 21:38 
GeneralVideo Capture Problem Pin
tunerica17-May-04 21:10
tunerica17-May-04 21:10 
Been trying to make a program to capture and process frames to detect movement, first trying to set up a window with the video capture window. Getting a problem when I try to build the project.

Here is the error:

wmcaptest.obj : error LNK2001: unresolved external symbol _capGetDriverDescriptionA@20
wmcaptest.obj : error LNK2001: unresolved external symbol _capCreateCaptureWindowA@32
Debug/CameraControl.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

Here is the code:

//File: WM_CAP test.cpp

#include <windows.h>
#include "resource.h"
#include <vfw.h>
#include <commdlg.h>
#include "wmcaptest.h"



HWND captureWindow; //Main capture window handle
HINSTANCE hInstance; //Handle to the instance that contains the window procedure for the class
HMENU hMenuMain; //Handle to the main menu for the class
WORD gwDeviceIndex;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); //Required for the WndClass struct
static void CenterCaptureWindow(HWND, HWND);
static void ResizeMainWindow(int, int, HWND, HWND);
static void StartNewVideoChannel(HWND, HWND, WORD);


CAPDRIVERCAPS gCapDriverCaps;
CAPSTATUS gCapStatus;


//Winmain: application entry point function

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wndClass;
static TCHAR windowName[] = TEXT ("Camera Motion Detection") ;
HWND cWindow;
MSG msg;

//Setting all the necessary values for the wndClass struct
//First checks to see whether this is the first instance of the application or not

if(!hPrevInstance)
{
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = NULL;
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = windowName;


//Attempts to register the class for future calls of the CreateWindow function
//If unsuccessful the program will display a message box letting the user know what happened

if (!RegisterClass (&wndClass))
{
MessageBox (NULL, TEXT ("Could not init Programm"),
windowName, MB_ICONERROR) ;
return 0;
}
}


//Create the applications main window using the create window function

cWindow = CreateWindow(
windowName,
TEXT ("Frame Capture V1.0"),
WS_CLIPCHILDREN |
WS_MAXIMIZE |
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
320, 240,
NULL,
NULL,
hInstance,
NULL);

ShowWindow (cWindow, nCmdShow) ;
UpdateWindow (cWindow) ;

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return msg.wParam;

}


//Application main window procedure

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LPSTR szMessage = "First time run";
HMENU hSubMenu;
WORD wDriverCount = 0;

switch(message)
{
case WM_CREATE:
WORD wIndex;
TCHAR achDeviceName[80];
TCHAR achDeviceVersion[100];
TCHAR achBuffer[100];
DWORD dwError;


//Create an instance of the main window
hInstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE);

//Link the menu to the instance
hMenuMain = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
SetMenu (hwnd, hMenuMain);
hSubMenu = GetSubMenu(hMenuMain,1);


//Create the capture window
captureWindow = capCreateCaptureWindow((LPTSTR)TEXT("Capture Window"),
WS_CHILD | WS_VISIBLE,
0, 0, 160, 120,
hwnd, 0);

//Try to connect one of the MSVIDEO drivers
for (wIndex = 0 ; wIndex < MAXVIDDRIVERS ; wIndex++)
{
if (capGetDriverDescription(wIndex,
(LPTSTR)achDeviceName, sizeof(achDeviceName)/ sizeof(TCHAR),
(LPTSTR)achDeviceVersion, sizeof(achDeviceVersion)/sizeof(TCHAR)))
{

// Append driver name to "Options" list in menu
wsprintf(achBuffer, TEXT("&%d %s"), wIndex, (LPTSTR)achDeviceName) ;
AppendMenu(hSubMenu, MF_ENABLED, IDM_O_DRIVERS+wIndex, achBuffer) ;

if (wDriverCount++ == 0)
{
// Only if no other driver is already connected
dwError = capDriverConnect(captureWindow, wIndex);

if (dwError)
{
CheckMenuItem(hMenuMain, IDM_O_DRIVERS+wIndex, MF_BYCOMMAND | MF_CHECKED) ;
gwDeviceIndex = wIndex ;
}
}
} // end of if (capGetDriverDesc..())
}

// Now refresh menu, position capture window, start driver etc
DrawMenuBar(hwnd);
CenterCaptureWindow(hwnd, captureWindow);
StartNewVideoChannel(hwnd, captureWindow, gwDeviceIndex);

break;


case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 70, 50, szMessage, strlen(szMessage));
EndPaint(hwnd, &ps);
break;

case WM_CLOSE:
DestroyWindow(hwnd);
break;

case WM_DESTROY:
PostQuitMessage(0);
break;

default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}

static void CenterCaptureWindow(HWND hWndMain, HWND hWndCap)
{

RECT MainRect ;
RECT CapRect ;
WORD wCapXPos ;
WORD wCapYPos ;

// Get the sizes of main and capture windows and
// calculate the location for centering
GetClientRect(hWndMain, &MainRect) ;
GetClientRect(hWndCap, &CapRect) ;
wCapXPos = max(0, ((MainRect.right -MainRect.left) - (CapRect.right - CapRect.left)) / 2) ;
wCapYPos = max(0, ((MainRect.bottom - MainRect.top) - (CapRect.bottom - CapRect.top)) / 2) ;

// Position the capture window at the required location
MoveWindow(hWndCap, wCapXPos, wCapYPos, (CapRect.right - CapRect.left),
(CapRect.bottom - CapRect.top), TRUE) ;
}

static void ResizeMainWindow(int XPos, int YPos, HWND hWndMain, HWND hWndCap)
{
////////////////////////////////////////////////////////////////////////
// hWndM: Application main window handle
// hWndC: Capture window handle
////////////////////////////////////////////////////////////////////////

RECT CapRect ;
// Get the sizes of main window
GetClientRect(hWndCap, &CapRect) ;


// Position the capture window at the required location
MoveWindow(hWndMain, XPos, YPos, (CapRect.right - CapRect.left + 7),
(CapRect.bottom - CapRect.top + 45), TRUE) ;
}

//
// StartNewVideoChannel: Gets Selected Driver's Caps -- Updates menu,
// Checks Image Size -- Resizes display window,
// Enables Preview (at 15 FPS rate)
//
static void StartNewVideoChannel(HWND hWndM, HWND hWndC, WORD wIndex)
{
////////////////////////////////////////////////////////////////////////
// hWndM: Application main window handle
// hWndC: Capture window handle
// wIndex: Selected capture driver index
////////////////////////////////////////////////////////////////////////



// Get capture driver settings and update menu
capDriverGetCaps(hWndC, &gCapDriverCaps, sizeof(CAPDRIVERCAPS)) ;
EnableMenuItem(hMenuMain, ID_SETTINGS_VIDEOFORMAT, MF_BYCOMMAND |
gCapDriverCaps.fHasDlgVideoFormat ? MF_ENABLED : MF_GRAYED) ;
EnableMenuItem(hMenuMain, ID_SETTINGS_VIDEOSOURCE, MF_BYCOMMAND |
gCapDriverCaps.fHasDlgVideoSource ? MF_ENABLED : MF_GRAYED) ;


// Get video format and adjust capture window
capGetStatus(hWndC, &gCapStatus, sizeof(CAPSTATUS)) ;
SetWindowPos(hWndC, NULL, 0, 0, gCapStatus.uiImageWidth,
gCapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE) ;


capPreviewRate(hWndC, MS_FOR_15FPS) ;
capOverlay(hWndC, TRUE) ;


}

-----------------

Any help on this would be greatly appreciated. As it is proving a great stumbling block and doesn't make any sense to me.
GeneralRe: Video Capture Problem Pin
Prakash Nadar17-May-04 21:22
Prakash Nadar17-May-04 21:22 
GeneralRe: Video Capture Problem Pin
tunerica17-May-04 21:28
tunerica17-May-04 21:28 
GeneralDivider between menu, toolbar, etc Pin
alex.barylski17-May-04 21:08
alex.barylski17-May-04 21:08 
GeneralRe: Divider between menu, toolbar, etc Pin
Prakash Nadar17-May-04 21:16
Prakash Nadar17-May-04 21:16 
GeneralRe: Divider between menu, toolbar, etc Pin
alex.barylski17-May-04 21:21
alex.barylski17-May-04 21:21 
GeneralRe: Divider between menu, toolbar, etc Pin
Prakash Nadar17-May-04 21:46
Prakash Nadar17-May-04 21:46 
GeneralRe: Divider between menu, toolbar, etc Pin
alex.barylski18-May-04 2:25
alex.barylski18-May-04 2:25 
Generalselected text in a Edit Box Pin
Shuang. Wu17-May-04 21:02
Shuang. Wu17-May-04 21:02 
GeneralRe: selected text in a Edit Box Pin
alex.barylski17-May-04 21:19
alex.barylski17-May-04 21:19 
GeneralRe: selected text in a Edit Box Pin
Shuang. Wu17-May-04 21:43
Shuang. Wu17-May-04 21:43 
GeneralRe: selected text in a Edit Box Pin
alex.barylski18-May-04 2:20
alex.barylski18-May-04 2:20 
GeneralRe: selected text in a Edit Box Pin
David Crow18-May-04 2:27
David Crow18-May-04 2:27 
GeneralTab pages ,, communication problem!! Pin
rohit.dhamija17-May-04 20:55
rohit.dhamija17-May-04 20:55 
GeneralRe: Tab pages ,, communication problem!! Pin
Prakash Nadar17-May-04 22:02
Prakash Nadar17-May-04 22:02 
QuestionHelp with class's ??? Pin
contemptx17-May-04 20:45
contemptx17-May-04 20:45 
AnswerRe: Help with class's ??? Pin
David Crow18-May-04 2:29
David Crow18-May-04 2:29 
Generalchart graph in MFC Pin
nnvidya17-May-04 20:32
nnvidya17-May-04 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.