zorro59 Posted November 10, 2011 Report Posted November 10, 2011 (edited) void main(){ camhwnd = capCreateCaptureWindow ("camera window", WS_CHILD , 0,0, 320, 240, GetDesktopWindow(), 0); SendMessage(camhwnd,WM_CAP_DRIVER_CONNECT,0,0); cout<<GetLastError()<<endl;//returns 995 //SendMessage(camhwnd,WM_CAP_DLG_VIDEOSOURCE,0,0); ShowWindow(camhwnd,SW_SHOW); SendMessage(camhwnd, WM_CAP_DRIVER_CONNECT,0,0); SendMessage(camhwnd, WM_CAP_SET_SCALE, true , 0); SendMessage(camhwnd, WM_CAP_SET_PREVIEWRATE, 10, 0); SendMessage(camhwnd, WM_CAP_SET_PREVIEW, true , 0); cout<<GetLastError(); for (int i=0; i<10; i++) { capFileSaveDIB(camhwnd, "file.bmp"); ConvertImage(L"file.bmp", L"file.jpeg", L"image/jpeg", 70); system("PAUSE"); }}Codul functioneaza daca este rulat dintr-o aplicatie win32, dar cand incerc sa rulez din consola primesc error code 995 (nu se creaza fereastra). Stie cineva cum sa trec de asta/alta metoda? Edited November 10, 2011 by zorro59 Quote
nedo Posted November 10, 2011 Report Posted November 10, 2011 (edited) Prima chestie.Include si headerele.A 2-a, foloseste int main si return 0 la final, e mai bine asa.A 3-a, in mod normal trebuie sa aloci un handle pentru fereastra. Nu mai tin minte exact, aveam pe undeva un cod pentru asta.Le: Incearca sa incluzi windows.h si sa adaugi AllocConsole(); inainte de primele comenzi.Poti sa incerci sa te inspiri din codul postat aici de catre parazitul29. Si el face cam acelasi lucru. Creeaza o aplicatie consola care totusi acceseaza ferestre. Edited November 10, 2011 by nedo Quote
Nytro Posted November 10, 2011 Report Posted November 10, 2011 Daca deschizi cmd cu "Run as Administrator" e la fel? Zic asta pentru ca m-am chinuit si eu ore sa inteleg un cod valid care nu mergea pentru ca trebuia rulat ca Administrator... PS: Posteaza codul sursa daca poti, eu as fi interesat sa ma uit peste el. Quote
zorro59 Posted November 10, 2011 Author Report Posted November 10, 2011 (edited) Linkul nu merge. In legatura cu headers, nu le-am inclus pentru ca este o parte dintr-un proiect mai amplu.LE: nici cu "run as administrator" nu merge.LE2: am gasit codul de care spui tu, dar nu are legatura cu ceea ce vreau eu. El trebuie sa trimita un mesaj unei ferestre care exista deja, eu am nevoie sa o creez. Edited November 10, 2011 by zorro59 Quote
nedo Posted November 10, 2011 Report Posted November 10, 2011 Am pus link-ul corect, nu stiu exact ce am copiat acolo .... Quote
aphex Posted November 10, 2011 Report Posted November 10, 2011 #include <iostream>#include <windows.h>long __stdcall WindowProcedure( HWND window, unsigned int msg, WPARAM wp, LPARAM lp ){ switch(msg) { case WM_DESTROY: std::cout << "\ndestroying window\n" ; PostQuitMessage(0) ; return 0L ; case WM_LBUTTONDOWN: std::cout << "\nmouse left button down at (" << LOWORD(lp) << ',' << HIWORD(lp) << ")\n" ; // fall thru default: std::cout << '.' ; return DefWindowProc( window, msg, wp, lp ) ; }}int main(){ std::cout << "hello world!\n" ; const char* const myclass = "myclass" ; WNDCLASSEX wndclass = { sizeof(WNDCLASSEX), CS_DBLCLKS, WindowProcedure, 0, 0, GetModuleHandle(0), LoadIcon(0,IDI_APPLICATION), LoadCursor(0,IDC_ARROW), HBRUSH(COLOR_WINDOW+1), 0, myclass, LoadIcon(0,IDI_APPLICATION) } ; if( RegisterClassEx(&wndclass) ) { HWND window = CreateWindowEx( 0, myclass, "title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, GetModuleHandle(0), 0 ) ; if(window) { ShowWindow( window, SW_SHOWDEFAULT ) ; MSG msg ; while( GetMessage( &msg, 0, 0, 0 ) ) DispatchMessage(&msg) ; } }} 1 1 Quote
zorro59 Posted November 10, 2011 Author Report Posted November 10, 2011 Perfect, asa merge.Multumesc mult! Quote