sowas wie ein ie-modul



  • Aaaaaaah!!!!!

    braucht das zufällig ein neueres PSDK? ich bekomm nämlich 37 fehlermeldungen!



  • Schon möglich 🕶 - was für Fehlermeldungen bekommst du denn?



  • --------------------Configuration: ieplugin - Win32 Debug--------------------
    Compiling...
    ieplugin.cpp
    E:\Projects\ieplugin\ieplugin.cpp(9) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(9) : error C2501: '_Module' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(9) : error C2371: '_Module' : redefinition; different basic types
            E:\Projects\ieplugin\ieplugin.cpp(4) : see declaration of '_Module'
    E:\Projects\ieplugin\ieplugin.cpp(9) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(13) : error C2501: 'm_hBrowser' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(13) : error C2065: 'hParent' : undeclared identifier
    E:\Projects\ieplugin\ieplugin.cpp(13) : error C2065: 'MY_BROWSER_ID' : undeclared identifier
    E:\Projects\ieplugin\ieplugin.cpp(13) : error C2065: 'hInst' : undeclared identifier
    E:\Projects\ieplugin\ieplugin.cpp(17) : error C2501: 'AtlAxGetControl' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(17) : error C2078: too many initializers
    E:\Projects\ieplugin\ieplugin.cpp(17) : error C2440: 'initializing' : cannot convert from 'struct IUnknown ** ' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    E:\Projects\ieplugin\ieplugin.cpp(20) : error C2501: 'VariantInit' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(20) : error C2373: 'VariantInit' : redefinition; different type modifiers
            e:\vc98\include\oleauto.h(124) : see declaration of 'VariantInit'
    E:\Projects\ieplugin\ieplugin.cpp(20) : error C2440: 'initializing' : cannot convert from 'struct tagVARIANT *' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    E:\Projects\ieplugin\ieplugin.cpp(21) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(21) : error C2501: 'var' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(21) : error C2371: 'var' : redefinition; different basic types
            E:\Projects\ieplugin\ieplugin.cpp(19) : see declaration of 'var'
    E:\Projects\ieplugin\ieplugin.cpp(21) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(22) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(22) : error C2501: 'var' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(22) : error C2371: 'var' : redefinition; different basic types
            E:\Projects\ieplugin\ieplugin.cpp(19) : see declaration of 'var'
    E:\Projects\ieplugin\ieplugin.cpp(22) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(25) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(25) : error C2501: 'pDisp' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(25) : error C2371: 'pDisp' : redefinition; different basic types
            E:\Projects\ieplugin\ieplugin.cpp(24) : see declaration of 'pDisp'
    E:\Projects\ieplugin\ieplugin.cpp(25) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(27) : error C2501: 'VariantClear' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(27) : error C2373: 'VariantClear' : redefinition; different type modifiers
            e:\vc98\include\oleauto.h(125) : see declaration of 'VariantClear'
    E:\Projects\ieplugin\ieplugin.cpp(27) : error C2440: 'initializing' : cannot convert from 'struct tagVARIANT *' to 'int'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    E:\Projects\ieplugin\ieplugin.cpp(28) : error C2143: syntax error : missing ';' before '->'
    E:\Projects\ieplugin\ieplugin.cpp(28) : error C2501: 'pUnk' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(28) : error C2040: 'pUnk' : 'int' differs in levels of indirection from 'struct IUnknown *'
    E:\Projects\ieplugin\ieplugin.cpp(28) : error C2143: syntax error : missing ';' before '->'
    E:\Projects\ieplugin\ieplugin.cpp(32) : error C2143: syntax error : missing ';' before '.'
    E:\Projects\ieplugin\ieplugin.cpp(32) : error C2501: '_Module' : missing storage-class or type specifiers
    E:\Projects\ieplugin\ieplugin.cpp(32) : error C2371: '_Module' : redefinition; different basic types
            E:\Projects\ieplugin\ieplugin.cpp(4) : see declaration of '_Module'
    E:\Projects\ieplugin\ieplugin.cpp(32) : error C2143: syntax error : missing ';' before '.'
    Error executing cl.exe.
    
    ieplugin.exe - 37 error(s), 0 warning(s)
    


  • Welchen Code hast du denn jetzt verwendet?



  • // ... 
    // Für ActiveX 
    #include <atlbase.h> 
    CComModule _Module; 
    #include <atlcom.h> 
    #include <atlhost.h> 
    // ... 
    // Am Anfang von WinMain: 
    _Module.Init(0,hInst); 
    AtlAxWinInit(); 
    // ... 
    // Browser-Control erstellen: 
    m_hBrowser = CreateWindowEx(0,TEXT("AtlAxWin"),TEXT("{8856F961-340A-11D0-A96B-00C04FD705A2}"),WS_CHILD | WS_BORDER | WS_VISIBLE,0,0,200,200,hParent,(HMENU) MY_BROWSER_ID,hInst,0); 
    // ... 
    // Website anzeigen: 
    IUnknown *pUnk = 0; 
    AtlAxGetControl(m_hBrowser,&pUnk); 
    
    VARIANTARG var; 
    VariantInit(&var); 
    var.vt       = VT_BSTR; 
    var.bstrVal  = SysAllocString(TEXT("http://www.magiccreating.de.vu")); 
    
    CComDispatchDriver pDisp(pUnk); 
    pDisp.Invoke1(TEXT("Navigate"),&var); 
    
    VariantClear(&var); 
    pUnk->Release(); 
    // ... 
    // Am Ende von WinMain: 
    AtlAxWinTerm(); 
    _Module.Term();
    


  • Binde zu Beginn auf jeden Fall man noch windows.h ein



  • immernoch 37 fehler 😞



  • Zeig doch mal die ersten 10 bis 20 Zeilen deines Quelltextes an (nicht nur Ausschnitte) - vermutlich hast du da irgendwo den Fehler sitzen 🙄



  • Der letzte Fehler tritt in Zeile 32 auf (E:\Projects\ieplugin\ieplugin.cpp(32)), also poste mal die ersten 33 Zeilen Deines Quelltextes ungekürzt.

    Noch besser wäre, wenn Du per '//' Kommentar hinter den betroffenen Zeilen anzeigst, in welchen Zeilen die Fehler sitzen (dann muß man nicht mühselig nachzählen)...



  • ähm, das ist der ganze quelltext. und zeigen, wo der fehler sitzen, bringt ja auch nicht viel, ist ja in fast jeder zeile 🙂



  • oh oh, ich bin echt zu blöd für die welt! ich hab vergessen das ganze in WinMain zu machen!!!

    tut mir leid für euren unnötigen aufwand, schande über mich...



  • jetzt gibts noch 2 fehlermeldungen:

    1:

    E:\Projects\ieplugin\ieplugin.cpp(27) : error C2664: 'SysAllocString' : cannot convert parameter 1 from 'char [31]' to 'const unsigned short *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    in der zeile steht

    var.bstrVal  = SysAllocString(TEXT("http://www.magiccreating.de.vu"));
    

    2.

    E:\Projects\ieplugin\ieplugin.cpp(30) : error C2664: 'long __thiscall ATL::CComDispatchDriver::Invoke1(long,struct tagVARIANT *,struct tagVARIANT *)' : cannot convert parameter 1 from 'char [9]' to 'long'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast

    dort steht

    pDisp.Invoke1(TEXT("Navigate"),&var);
    


  • Wenn du den Code so gelassen hättest wie in dem Beispiel hättest du diese Fehler wohl nicht bekommen :p :

    var.bstrVal  = SysAllocString((OLECHAR*)TEXT("http://www.magiccreating.de.vu")); 
    // [...]
    pDisp.Invoke1((LPCOLESTR)TEXT("Navigate"),&var);
    


  • oh, ich wusste gar nicht mehr, dass ich das entfernt hatte....

    jetzt hab ich's noch mal ganz neu gemacht, in ganz neuer form, und zwar so:

    #include <windows.h>
    // ... 
    // Für ActiveX 
    #include <atlbase.h> 
    CComModule _Module; 
    #include <atlcom.h> 
    #include <atlhost.h> 
    // ... 
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    	_Module.Init(0,hInst); 
    	AtlAxWinInit();
    
    	static TCHAR szAppName[] = TEXT("test");
    	HWND		hWnd;
    	MSG			msg;
    	WNDCLASS	wndclass;
    
    	wndclass.style		= CS_HREDRAW | CS_VREDRAW;
    	wndclass.lpfnWndProc	= WndProc;
    	wndclass.cbClsExtra	= 0;
    	wndclass.cbWndExtra	= 0;
    	wndclass.hInstance	= hInst;
    	wndclass.hIcon		= LoadIcon(NULL, IDI_APPLICATION);
    	wndclass.hCursor	= LoadCursor(NULL, IDC_ARROW);
    	wndclass.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
    	wndclass.lpszMenuName	= NULL;
    	wndclass.lpszClassName	= szAppName;
    
    	RegisterClass (&wndclass);
    
    	hWnd = CreateWindow(szAppName, TEXT("test"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL);
    
    	ShowWindow(hWnd, iCmdShow);
    	UpdateWindow(hWnd);
    
    	while (GetMessage(&msg, NULL, 0, 0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	AtlAxWinTerm(); 
    	_Module.Term();
    	return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	HWND m_hBrowser;
    	HINSTANCE hInst;
    
    	switch (message)
    	{
    	case WM_CREATE:
    		hInst = ((LPCREATESTRUCT)lParam)->hInstance;
    		m_hBrowser = CreateWindowEx(0,TEXT("AtlAxWin"),TEXT("{8856F961-340A-11D0-A96B-00C04FD705A2}"),WS_CHILD | WS_BORDER | WS_VISIBLE,0,0,200,200,hWnd,(HMENU) 4003,hInst,0);  
    
    		IUnknown *pUnk = 0;  
    		AtlAxGetControl(m_hBrowser,&pUnk);  
    
    		VARIANTARG var;  
    		VariantInit(&var);  
    		var.vt       = VT_BSTR;  
    		var.bstrVal  = SysAllocString((OLECHAR*)TEXT("http://www.magiccreating.de.vu"));  
    
    		CComDispatchDriver pDisp(pUnk);  
    		pDisp.Invoke1((LPCOLESTR)TEXT("Navigate"),&var);  
    
    		VariantClear(&var);  
    		pUnk->Release();  
    		return 0;
    
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    	}
    	return DefWindowProc(hWnd, message, wParam, lParam);
    }
    

    aber jetzt kommen die fehlermeldungen:

    E:\Projects\ieplugin\ieplugin.cpp(79) : error C2360: initialization of 'pDisp' is skipped by 'case' label
    E:\Projects\ieplugin\ieplugin.cpp(72) : see declaration of 'pDisp'
    E:\Projects\ieplugin\ieplugin.cpp(79) : error C2360: initialization of 'pUnk' is skipped by 'case' label
    E:\Projects\ieplugin\ieplugin.cpp(64) : see declaration of 'pUnk'

    in der 79. zeile ist beginnt der case-zweig zu WM_DESTROY.



  • case WM_CREATE:
    {
       ...
    }
    retrun 0;
    


  • Wenn du in einem switch Variable deklarierst musst du den entsprechenden cas-Block in { } einschließen - außerhalb dieses Blockes kannst du dann aber nicht mehr darauf zugreifen. Falls du das brauchst musst du sie in der WndProc static machen



  • oh, wusste ich gar nicht.

    jetzt wird das ganze zwar (endlich) kompiliert, aber es wird keine webseite angezeigt, nur ein schwarzer rahmen von dem childfenster und sonst nichts...



  • Greifst du evtl. in der WndProc an mehreren Stellen auf m_hBrowser oder hInst zu? Falls ja solltest du diese static machen, falls nein kannst du sie gleich in WM_CREATE deklarieren 😉



  • ich machs eben so, wie ich's oben gepostet habe 🙂

    tut mir leid wenn ich euch nerve



  • Sorry, aber man sollte doch wenigstens ansatzweise verstehen, was man da kopiert ...

    var.bstrVal  = SysAllocString((OLECHAR*)TEXT("http://www.magiccreating.de.vu"));
    

    Was soll denn das geben?

    pDisp.Invoke1((LPCOLESTR)TEXT("Navigate"),&var);
    

    Und was soll das geben?

    Du mußt UNICODE-Strings übergeben, blindes casten hilft hier nicht!


Anmelden zum Antworten