<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SendMessage]]></title><description><![CDATA[<p>Hallo zusammen, ich bin es wieder mal!</p>
<p>Beim auftarten des Programms wird die <a href="http://www.google.ch" rel="nofollow">www.google.ch</a> URL angezeigt.<br />
Wenn ich nun im Menu den Eintrag Forum anwähle (ID_FORUM), so sollte der Wert von cURL (<a href="http://www.irgendeinforum.ch" rel="nofollow">www.irgendeinforum.ch</a>) an die WinMain bzw, an</p>
<pre><code>pIwb-&gt;Navigate(strBuffer,0,0,0,0); übergeben werden.
</code></pre>
<p>Ich versuche schon den ganzen Tag dies mit SendMessage zu lösen, komme aber nicht mehr weiter.</p>
<p>Mit</p>
<pre><code>SetWindowText(hWnd, cURL);
</code></pre>
<p>kann ich den Text der cURL an das Fenster senden.</p>
<p>Auf das Wochenende und vielen dank für die Hilfe,<br />
Sotares</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;exdisp.h&gt;
#include &quot;resource.h&quot;

 char cURL[100];
 HWND container;

 /***************************************************************************/
 LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam )
 {   
     HMENU hMenu;

     switch(messg)
     {
		case WM_CREATE:
		{
		char x[100]=&quot;www.google.ch&quot;;
		strcpy(cURL, x); 
		}

           case WM_COMMAND:
	   hMenu = GetMenu (hWnd);

			switch(LOWORD (wParam))
			{
				case ID_FORUM:
				char y[100]=&quot;www.irgeneinforum.ch&quot;;
				strcpy(cURL, y);
				//SendMessage ??
				break;
			}			 

	case WM_SIZE:
             MoveWindow(container,0,0,LOWORD(lParam), HIWORD(lParam),1);
             break;

        case WM_CLOSE:
             DestroyWindow(hWnd);
             break;

        case WM_DESTROY:
             PostQuitMessage( 0 );
             break;

        default:
             return( DefWindowProc( hWnd, messg, wParam, lParam ) );
     }
     return 0;

 /***************************************************************************/
 }
 /********************* Funktion WinMain ************************************************/
 int WINAPI WinMain( HINSTANCE hInst,HINSTANCE hPreInst,LPSTR lpszCmdLine, int nCmdShow )
 {
     WNDCLASS wc;
     char NomClasse[] = &quot;container&quot;;
     wc.style = CS_HREDRAW | CS_VREDRAW;
	 wc.lpszClassName	= NomClasse;
     wc.hInstance		= hInst;
     wc.lpfnWndProc     = WndProc;
     wc.hCursor			= LoadCursor( 0, IDC_ARROW );
     wc.hIcon			= LoadIcon( hInst, MAKEINTRESOURCE (IDI_ICON));
	 wc.lpszMenuName	= MAKEINTRESOURCE(IDR_MENU1);
	 wc.hbrBackground	= 0;
     wc.style			= 0;
     wc.cbClsExtra		= 0;
     wc.cbWndExtra		= 0;

     if (!RegisterClass(&amp;wc)) return 0;

     HWND hWnd = CreateWindow(
		 NomClasse,
		 &quot;container Activex&quot;,WS_OVERLAPPEDWINDOW,
		 0,0,800,575,0,NULL,hInst,0);

	 ShowWindow(hWnd, nCmdShow );
     UpdateWindow( hWnd );

     HINSTANCE hDLL = LoadLibrary(&quot;atl.dll&quot;);
     typedef HRESULT (WINAPI *PAttachControl)(IUnknown*, HWND,IUnknown**);
     PAttachControl AtlAxAttachControl = (PAttachControl) GetProcAddress(hDLL, &quot;AtlAxAttachControl&quot;);
     RECT rect;
     GetClientRect(hWnd,&amp;rect);
     container=CreateWindowEx(WS_EX_CLIENTEDGE,&quot;EDIT&quot;,&quot;&quot;,WS_CHILD | WS_VISIBLE,0,0,rect.right,rect.bottom,hWnd,0,0,0);
     CoInitialize(0);
     IWebBrowser2 *pIwb;
     CoCreateInstance(CLSID_WebBrowser,0,CLSCTX_ALL,IID_IWebBrowser2,(void**)&amp;pIwb);
     AtlAxAttachControl(pIwb,container,0);

	 WCHAR strBuffer[100];
	 MultiByteToWideChar(CP_ACP, 0, cURL, -1, strBuffer, sizeof(strBuffer));

     pIwb-&gt;Navigate(strBuffer,0,0,0,0);

     MSG Msg;
     while( GetMessage(&amp;Msg, 0, 0, 0))
     {
         TranslateMessage( &amp;Msg );
         DispatchMessage( &amp;Msg );
     }

     pIwb-&gt;Release();
     CoUninitialize();        
     FreeLibrary(hDLL);
     return( Msg.wParam);
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/165968/sendmessage</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 02:39:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/165968.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 24 Nov 2006 18:33:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SendMessage on Fri, 24 Nov 2006 18:33:07 GMT]]></title><description><![CDATA[<p>Hallo zusammen, ich bin es wieder mal!</p>
<p>Beim auftarten des Programms wird die <a href="http://www.google.ch" rel="nofollow">www.google.ch</a> URL angezeigt.<br />
Wenn ich nun im Menu den Eintrag Forum anwähle (ID_FORUM), so sollte der Wert von cURL (<a href="http://www.irgendeinforum.ch" rel="nofollow">www.irgendeinforum.ch</a>) an die WinMain bzw, an</p>
<pre><code>pIwb-&gt;Navigate(strBuffer,0,0,0,0); übergeben werden.
</code></pre>
<p>Ich versuche schon den ganzen Tag dies mit SendMessage zu lösen, komme aber nicht mehr weiter.</p>
<p>Mit</p>
<pre><code>SetWindowText(hWnd, cURL);
</code></pre>
<p>kann ich den Text der cURL an das Fenster senden.</p>
<p>Auf das Wochenende und vielen dank für die Hilfe,<br />
Sotares</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;exdisp.h&gt;
#include &quot;resource.h&quot;

 char cURL[100];
 HWND container;

 /***************************************************************************/
 LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam )
 {   
     HMENU hMenu;

     switch(messg)
     {
		case WM_CREATE:
		{
		char x[100]=&quot;www.google.ch&quot;;
		strcpy(cURL, x); 
		}

           case WM_COMMAND:
	   hMenu = GetMenu (hWnd);

			switch(LOWORD (wParam))
			{
				case ID_FORUM:
				char y[100]=&quot;www.irgeneinforum.ch&quot;;
				strcpy(cURL, y);
				//SendMessage ??
				break;
			}			 

	case WM_SIZE:
             MoveWindow(container,0,0,LOWORD(lParam), HIWORD(lParam),1);
             break;

        case WM_CLOSE:
             DestroyWindow(hWnd);
             break;

        case WM_DESTROY:
             PostQuitMessage( 0 );
             break;

        default:
             return( DefWindowProc( hWnd, messg, wParam, lParam ) );
     }
     return 0;

 /***************************************************************************/
 }
 /********************* Funktion WinMain ************************************************/
 int WINAPI WinMain( HINSTANCE hInst,HINSTANCE hPreInst,LPSTR lpszCmdLine, int nCmdShow )
 {
     WNDCLASS wc;
     char NomClasse[] = &quot;container&quot;;
     wc.style = CS_HREDRAW | CS_VREDRAW;
	 wc.lpszClassName	= NomClasse;
     wc.hInstance		= hInst;
     wc.lpfnWndProc     = WndProc;
     wc.hCursor			= LoadCursor( 0, IDC_ARROW );
     wc.hIcon			= LoadIcon( hInst, MAKEINTRESOURCE (IDI_ICON));
	 wc.lpszMenuName	= MAKEINTRESOURCE(IDR_MENU1);
	 wc.hbrBackground	= 0;
     wc.style			= 0;
     wc.cbClsExtra		= 0;
     wc.cbWndExtra		= 0;

     if (!RegisterClass(&amp;wc)) return 0;

     HWND hWnd = CreateWindow(
		 NomClasse,
		 &quot;container Activex&quot;,WS_OVERLAPPEDWINDOW,
		 0,0,800,575,0,NULL,hInst,0);

	 ShowWindow(hWnd, nCmdShow );
     UpdateWindow( hWnd );

     HINSTANCE hDLL = LoadLibrary(&quot;atl.dll&quot;);
     typedef HRESULT (WINAPI *PAttachControl)(IUnknown*, HWND,IUnknown**);
     PAttachControl AtlAxAttachControl = (PAttachControl) GetProcAddress(hDLL, &quot;AtlAxAttachControl&quot;);
     RECT rect;
     GetClientRect(hWnd,&amp;rect);
     container=CreateWindowEx(WS_EX_CLIENTEDGE,&quot;EDIT&quot;,&quot;&quot;,WS_CHILD | WS_VISIBLE,0,0,rect.right,rect.bottom,hWnd,0,0,0);
     CoInitialize(0);
     IWebBrowser2 *pIwb;
     CoCreateInstance(CLSID_WebBrowser,0,CLSCTX_ALL,IID_IWebBrowser2,(void**)&amp;pIwb);
     AtlAxAttachControl(pIwb,container,0);

	 WCHAR strBuffer[100];
	 MultiByteToWideChar(CP_ACP, 0, cURL, -1, strBuffer, sizeof(strBuffer));

     pIwb-&gt;Navigate(strBuffer,0,0,0,0);

     MSG Msg;
     while( GetMessage(&amp;Msg, 0, 0, 0))
     {
         TranslateMessage( &amp;Msg );
         DispatchMessage( &amp;Msg );
     }

     pIwb-&gt;Release();
     CoUninitialize();        
     FreeLibrary(hDLL);
     return( Msg.wParam);
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1180893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1180893</guid><dc:creator><![CDATA[Sotares]]></dc:creator><pubDate>Fri, 24 Nov 2006 18:33:07 GMT</pubDate></item><item><title><![CDATA[Reply to SendMessage on Fri, 24 Nov 2006 19:00:24 GMT]]></title><description><![CDATA[<p>Du Pfosten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Die WinMain ist doch kein Event Handler. Events handelt man in der WndProc bzw. noch besser gleich eigenen Event Handler Funktionen. Du musst den Kontext schon der WndProc mitteilen, dann kannst du in der WndProc schön selbst pDings-&gt;Navigate() aufrufen. Eine halbwegs einfache Methode ist über Set/GetWindowLongPtr().</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1180906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1180906</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 24 Nov 2006 19:00:24 GMT</pubDate></item><item><title><![CDATA[Reply to SendMessage on Sat, 25 Nov 2006 12:11:57 GMT]]></title><description><![CDATA[<p>Hallo hustbaer,<br />
ich habe den Code ein wenig abgeändert und es läuft alles zu meiner Zufriedenheit!</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;exdisp.h&gt;
#include &quot;resource.h&quot;

HWND container;

HINSTANCE hDLL = LoadLibrary(&quot;atl.dll&quot;);
typedef HRESULT (WINAPI *PAttachControl)(IUnknown*, HWND,IUnknown**);
PAttachControl AtlAxAttachControl = (PAttachControl) GetProcAddress(hDLL, &quot;AtlAxAttachControl&quot;);
RECT rect;
IWebBrowser2 *pIwb;

void SelectURL (char URL[100])
{
char cURL[100];
strcpy(cURL, URL);
WCHAR strBuffer[100];
MultiByteToWideChar(CP_ACP, 0, cURL, -1, strBuffer, sizeof(strBuffer));
pIwb-&gt;Navigate(strBuffer,0,0,0,0);
}

 /***************************************************************************/
 LRESULT CALLBACK WndProc( HWND hWnd, UINT messg, WPARAM wParam, LPARAM lParam )
 {  
     HMENU hMenu;

	 PAINTSTRUCT ps;
	 HDC hdc;

     switch(messg)
     {

		case WM_CREATE:
			{
			GetClientRect(hWnd,&amp;rect);
			container=CreateWindowEx(WS_EX_CLIENTEDGE,&quot;EDIT&quot;,&quot;&quot;,WS_CHILD | WS_VISIBLE,0,0,rect.right,rect.bottom,hWnd,0,0,0);
			CoInitialize(0);
			CoCreateInstance(CLSID_WebBrowser,0,CLSCTX_ALL,IID_IWebBrowser2,(void**)&amp;pIwb);
			AtlAxAttachControl(pIwb,container,0);

			SelectURL(&quot;www.google.ch&quot;);
			break;
			}

            case WM_COMMAND:
			hMenu = GetMenu (hWnd);

            switch(LOWORD (wParam))
            {
                case ID_URL1: {
					SelectURL(&quot;www.yahoo.ch&quot;);
					} break;

				case ID_URL2: {
					SelectURL(&quot;www.google.ch&quot;);
					} break;

            }             

		case WM_PAINT:
			{
			 hdc = BeginPaint (hWnd, &amp;ps);
			 EndPaint (hWnd, &amp;ps);
			 break;
			}

		case WM_SIZE:
             MoveWindow(container,0,0,LOWORD(lParam), HIWORD(lParam),1);
			 break;

		case WM_CLOSE:
             DestroyWindow(hWnd);
             break;

		case WM_DESTROY:
             PostQuitMessage( 0 );
             break;

        default:
             return( DefWindowProc( hWnd, messg, wParam, lParam ) );
     }
     return 0;

 /***************************************************************************/
 }
 /********************* Funktion WinMain ************************************************/
 int WINAPI WinMain( HINSTANCE hInst,HINSTANCE hPreInst,LPSTR lpszCmdLine, int nCmdShow )
 {
     WNDCLASS wc;
     char NomClasse[] = &quot;container&quot;;
     wc.style = CS_HREDRAW | CS_VREDRAW;
     wc.lpszClassName    = NomClasse;
     wc.hInstance        = hInst;
     wc.lpfnWndProc     = WndProc;
     wc.hCursor            = LoadCursor( 0, IDC_ARROW );
     wc.hIcon            = LoadIcon( hInst, MAKEINTRESOURCE (IDI_ICON));
     wc.lpszMenuName    = MAKEINTRESOURCE(IDR_MENU1);
     wc.hbrBackground    = 0;
     wc.style            = 0;
     wc.cbClsExtra        = 0;
     wc.cbWndExtra        = 0;

     if (!RegisterClass(&amp;wc)) return 0;

     HWND hWnd = CreateWindow(
         NomClasse,
         &quot;container Activex&quot;,WS_OVERLAPPEDWINDOW,
         0,0,800,575,0,NULL,hInst,0);

     ShowWindow(hWnd, nCmdShow );
     UpdateWindow( hWnd );

     MSG Msg;
     while( GetMessage(&amp;Msg, 0, 0, 0))
     {
         TranslateMessage( &amp;Msg );
         DispatchMessage( &amp;Msg );
     }

     pIwb-&gt;Release();
     CoUninitialize();        
     FreeLibrary(hDLL);
     return( Msg.wParam);
 }
</code></pre>
<p>Dein Vorschlag mit einem eigenen Event-Handler werde ich mal anschauen.<br />
(Ich arbeite erst seit einer Woche mit WinApi)</p>
<p>Mit freundlichn Grüsssen,<br />
&quot;Der Pfosten&quot;, Sotares</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1181181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1181181</guid><dc:creator><![CDATA[Sotares]]></dc:creator><pubDate>Sat, 25 Nov 2006 12:11:57 GMT</pubDate></item><item><title><![CDATA[Reply to SendMessage on Sun, 26 Nov 2006 00:16:12 GMT]]></title><description><![CDATA[<p>Ok, jetzt verwendest du halt ne globale Variable. Bei ganz einfachen kleinen Programmen ist das OK - soll das Teil irgendwann grösser werden, vielleicht sogar mehrere Browser-Fenster unterstützen würde ich es eher anders machen, wie gesagt eben über SetWindowLongPtr().</p>
<p>Und das mit den &quot;event handlern&quot; -- ich meinte bloss den Code der sich ums abarbeiten von Events kümmert in eine eigenen Funktion packen, im Prinzip sehr ähnlich deiner SelectURL Methode. Damit man die ganze &quot;Logik&quot; auf WndProc rausbekommt, und WndProc sich nurmehr ums &quot;verteilen&quot; der Messages an die &quot;handler&quot; kümmert, also im einfachsten Fall zu einem grossen switch-case zusammenschrumpft, wo jeder case bloss &quot;return Handler(...);&quot; macht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1181511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1181511</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 26 Nov 2006 00:16:12 GMT</pubDate></item></channel></rss>