<?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[Oeffnen-Dialog erscheint nicht]]></title><description><![CDATA[<p>Was habe ich falsch gemacht (habe auch versucht return 0; einzufuegen, da das auch schon der Fehler war)? Der Oeffnen-Dialog sollte bei Klick auf den Button erscheinen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
 #include &lt;commdlg.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const char szAppName[] = &quot;Ein eigenes Fenster mit Text und Button&quot;;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
  HWND       hWnd;
    MSG        msg;
    WNDCLASS   wc;
    wc.style         =  CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   =  WndProc;
   wc.cbClsExtra    =  0;
   wc.cbWndExtra    =  0;

   wc.hInstance     =  hInstance;
   wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
   wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
   wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.lpszClassName =  szAppName;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);

   hWnd = CreateWindow(szAppName,
                       &quot;Titelleiste :-p&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Fensterbreite              */
                       CW_USEDEFAULT,          /* Fensterhoehe               */
                       NULL,
                       NULL,
                       hInstance,
                       NULL);

ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);

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

return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  static HWND hButton;  //Buttons
static HWND hButton2;

     switch (message)
     {
     case WM_CREATE:   //Buttons
        {

hButton = CreateWindow(  &quot;button&quot;,
                                  &quot;juhee :-D&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hWnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);

                                  hButton2 = CreateWindow(  &quot;button&quot;,
                                                                  &quot;Beenden&quot;,
                                                                  WS_CHILD | WS_VISIBLE,
                                                                  0, 0, 0, 0,
                                                                  hWnd,
                                                                  NULL,
                                                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                                                  NULL);

         return 0;
      }
   case WM_SIZE:
      {

MoveWindow(hButton, LOWORD(lParam) / 2 - 80, HIWORD(lParam) - 30,
   160, 22, TRUE);
    MoveWindow(hButton2, LOWORD(lParam) / 2 - 80, HIWORD(lParam) - 60,
     160, 22, TRUE);
        return 0;
     }

case WM_COMMAND:
      {
         if (lParam == (LPARAM)hButton)
         {
            if (HIWORD(wParam) == BN_CLICKED)

          {
OPENFILENAME ofn;       // common dialog box structure
char szFile[260];       // buffer for file name
HWND hwnd;              // owner window
HANDLE hf;              // file handle

// Initialize OPENFILENAME
ZeroMemory(&amp;ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

// Display the Open dialog box. 

if (GetOpenFileName(&amp;ofn)==TRUE) 
    hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
        0, (LPSECURITY_ATTRIBUTES) NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL);     

}
         }

         if (lParam == (LPARAM)hButton2)  //Button2
         {
            if (HIWORD(wParam) == BN_CLICKED)
               MessageBox (0, &quot;Chasch denn guet klicke&quot;, &quot;Super! &quot;, 64);

               int Antwort=MessageBox (0, &quot;Zuemache !?&quot;, &quot;Super! &quot;,MB_ICONERROR| MB_YESNO);
               {
               if (IDYES==Antwort)

               MessageBox (0, &quot;Denn halt :-p&quot;, &quot;OK&quot;, MB_ICONWARNING);
               }
               if (IDYES==Antwort) {
               SendMessage(hWnd, WM_CLOSE, 0, 0);

               }
         }

         return 0;
      }

     case WM_PAINT: //Text
     {
     PAINTSTRUCT ps;
         HDC         hDC;
         const char  szText[] = &quot;Hallo, dies ist der Text.&quot;;
         const char szText2[]=&quot;Das isch nomol e Text!!!&quot;;
         hDC = BeginPaint(hWnd, &amp;ps);
         {

           TextOut(hDC, 50, 50, szText, sizeof(szText) - 1);
           TextOut (hDC, 90, 90, szText2, sizeof(szText2) -1);

           }
         EndPaint(hWnd, &amp;ps);

         return 0;       // ENDE neu Text
     }

     case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }

return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/190770/oeffnen-dialog-erscheint-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 17:22:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/190770.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Aug 2007 18:49:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Sun, 26 Aug 2007 18:49:10 GMT]]></title><description><![CDATA[<p>Was habe ich falsch gemacht (habe auch versucht return 0; einzufuegen, da das auch schon der Fehler war)? Der Oeffnen-Dialog sollte bei Klick auf den Button erscheinen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
 #include &lt;commdlg.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
const char szAppName[] = &quot;Ein eigenes Fenster mit Text und Button&quot;;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
  HWND       hWnd;
    MSG        msg;
    WNDCLASS   wc;
    wc.style         =  CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   =  WndProc;
   wc.cbClsExtra    =  0;
   wc.cbWndExtra    =  0;

   wc.hInstance     =  hInstance;
   wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
   wc.hIcon         =  LoadIcon(NULL,IDI_APPLICATION);
   wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.lpszClassName =  szAppName;
   wc.lpszMenuName  =  NULL;
   RegisterClass(&amp;wc);

   hWnd = CreateWindow(szAppName,
                       &quot;Titelleiste :-p&quot;,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,          /* X-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Y-Position auf dem Monitor */
                       CW_USEDEFAULT,          /* Fensterbreite              */
                       CW_USEDEFAULT,          /* Fensterhoehe               */
                       NULL,
                       NULL,
                       hInstance,
                       NULL);

ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);

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

return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  static HWND hButton;  //Buttons
static HWND hButton2;

     switch (message)
     {
     case WM_CREATE:   //Buttons
        {

hButton = CreateWindow(  &quot;button&quot;,
                                  &quot;juhee :-D&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hWnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);

                                  hButton2 = CreateWindow(  &quot;button&quot;,
                                                                  &quot;Beenden&quot;,
                                                                  WS_CHILD | WS_VISIBLE,
                                                                  0, 0, 0, 0,
                                                                  hWnd,
                                                                  NULL,
                                                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                                                  NULL);

         return 0;
      }
   case WM_SIZE:
      {

MoveWindow(hButton, LOWORD(lParam) / 2 - 80, HIWORD(lParam) - 30,
   160, 22, TRUE);
    MoveWindow(hButton2, LOWORD(lParam) / 2 - 80, HIWORD(lParam) - 60,
     160, 22, TRUE);
        return 0;
     }

case WM_COMMAND:
      {
         if (lParam == (LPARAM)hButton)
         {
            if (HIWORD(wParam) == BN_CLICKED)

          {
OPENFILENAME ofn;       // common dialog box structure
char szFile[260];       // buffer for file name
HWND hwnd;              // owner window
HANDLE hf;              // file handle

// Initialize OPENFILENAME
ZeroMemory(&amp;ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

// Display the Open dialog box. 

if (GetOpenFileName(&amp;ofn)==TRUE) 
    hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
        0, (LPSECURITY_ATTRIBUTES) NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL);     

}
         }

         if (lParam == (LPARAM)hButton2)  //Button2
         {
            if (HIWORD(wParam) == BN_CLICKED)
               MessageBox (0, &quot;Chasch denn guet klicke&quot;, &quot;Super! &quot;, 64);

               int Antwort=MessageBox (0, &quot;Zuemache !?&quot;, &quot;Super! &quot;,MB_ICONERROR| MB_YESNO);
               {
               if (IDYES==Antwort)

               MessageBox (0, &quot;Denn halt :-p&quot;, &quot;OK&quot;, MB_ICONWARNING);
               }
               if (IDYES==Antwort) {
               SendMessage(hWnd, WM_CLOSE, 0, 0);

               }
         }

         return 0;
      }

     case WM_PAINT: //Text
     {
     PAINTSTRUCT ps;
         HDC         hDC;
         const char  szText[] = &quot;Hallo, dies ist der Text.&quot;;
         const char szText2[]=&quot;Das isch nomol e Text!!!&quot;;
         hDC = BeginPaint(hWnd, &amp;ps);
         {

           TextOut(hDC, 50, 50, szText, sizeof(szText) - 1);
           TextOut (hDC, 90, 90, szText2, sizeof(szText2) -1);

           }
         EndPaint(hWnd, &amp;ps);

         return 0;       // ENDE neu Text
     }

     case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   }

return DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1352552</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352552</guid><dc:creator><![CDATA[APIAnfaenger]]></dc:creator><pubDate>Sun, 26 Aug 2007 18:49:10 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Sun, 26 Aug 2007 19:07:15 GMT]]></title><description><![CDATA[<p>Das Handle des &quot;Owner-Windows&quot; vom Oeffnen-Dialog ist nicht korrekt :</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
...
 HWND hwnd;  
//  ofn.hwndOwner = hwnd;
 ofn.hwndOwner = hWnd;
...
}
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352565</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 26 Aug 2007 19:07:15 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Sun, 26 Aug 2007 19:11:49 GMT]]></title><description><![CDATA[<p>also erstens:</p>
<p>es wäre wesentlich übersichtlicher gewesen, wenn du nur gepostet hättest, worauf es ankommt:</p>
<pre><code class="language-cpp">// ...
OPENFILENAME ofn;       // common dialog box structure
char szFile[260];       // buffer for file name
HWND hwnd;              // owner window
HANDLE hf;              // file handle

// Initialize OPENFILENAME
ZeroMemory(&amp;ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
// use the contents of szFile to initialize itself.
//
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

// Display the Open dialog box. 

if (GetOpenFileName(&amp;ofn)==TRUE) 
    hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
        0, (LPSECURITY_ATTRIBUTES) NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL);
// ...
</code></pre>
<p>zweitens:<br />
wer ab und zu in die MSDN guckt, weiß, dass OFN_FILEMUSTEXIST OFN_PATHMUSTEXIST beinhaltet.<br />
also ist das OFN_PATHMUSTEXIST sinnlos.</p>
<p>und drittens (das wichtigste zum Schluss^^):<br />
Microsoft lässt dir die Möglichkeit ein eigenes Dialogtemplate zu nutzen.<br />
also mache Windows erst klar, dass du den Standard-Dialog willst.<br />
ich mach das immer so:</p>
<pre><code class="language-cpp">// ...
			OPENFILENAME ofn;
			ofn.dwReserved = 0;
			ofn.Flags = OFN_ENABLESIZING|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_LONGNAMES;
			ofn.FlagsEx = 0;
			ofn.hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWL_HINSTANCE);
			ofn.hwndOwner = g_hFrameWnd;
			ofn.lCustData = NULL;
			ofn.lpfnHook = 0;
			ofn.lpstrCustomFilter = NULL;
			ofn.lpstrDefExt = &quot;TXT&quot;;
			PFileName pFN = (PFileName)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			char szFileName[MAX_PATH];
			if (pFN != NULL)
				strncpy_s(szFileName, MAX_PATH, pFN-&gt;szFileName, MAX_PATH);
			else
				szFileName[0] = '\0';
			ofn.lpstrFile = szFileName;
			ofn.lpstrFileTitle = NULL;
			ofn.lpstrFilter = &quot;Textdateien (*.txt)\0*.txt\0Alle Dateien\0*.*\0\0&quot;;
			ofn.lpstrInitialDir = NULL;
			ofn.lpstrTitle = NULL;
			ofn.lpTemplateName = NULL;
			ofn.lStructSize = sizeof(OPENFILENAME);
			ofn.nFileExtension = 0;
			ofn.nFileOffset = 0;
			ofn.nFilterIndex = 0;
			ofn.nMaxCustFilter = 0;
			ofn.nMaxFile = MAX_PATH;
			ofn.nMaxFileTitle = 0;
			ofn.pvReserved = NULL;
			if (GetOpenFileName(&amp;ofn) != FALSE)
// ...
</code></pre>
<p>das stammt aus einem Texteditor mit MDI von mir.</p>
<p>da fällt mir gleich noch was auf:<br />
man überprüft NIE, ob etwas gleich TRUE ist.<br />
denn FALSE wird IMMER als 0 definiert.<br />
TRUE ist jedoch != 0 und damit undefiniert.<br />
Es ist somit dem Compilerhersteller, oder bei der WinAPI Microsoft überlassen, welchen Wert TRUE hat.<br />
Wenn man aber überprüft, ob etwas ungleich FALSE ist, so ist man immer auf der sicheren Seite.</p>
<p>MfG DrakoXP</p>
<p>PS.:<br />
merker muss ich auch Recht geben.<br />
lass das</p>
<pre><code class="language-cpp">HWND hwnd;
</code></pre>
<p>weg und schreib</p>
<pre><code class="language-cpp">ofn.hwndOwner = hWnd;
</code></pre>
<p>denn das Handle bekommst du ja als Parameter und somit brauchst du nicht extra eine neue Handle-Variable deklarieren, die nichtmal einen definierten Wert besitzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352566</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sun, 26 Aug 2007 19:11:49 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 04:28:33 GMT]]></title><description><![CDATA[<p>Ach so! Danke!<br />
Lustigerweise ist der Ausschnitt aus der MSDN.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352678</guid><dc:creator><![CDATA[APIAnfaenger]]></dc:creator><pubDate>Mon, 27 Aug 2007 04:28:33 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 04:39:49 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>da fällt mir gleich noch was auf:<br />
man überprüft NIE, ob etwas gleich TRUE ist.<br />
denn FALSE wird IMMER als 0 definiert.<br />
TRUE ist jedoch != 0 und damit undefiniert.<br />
Es ist somit dem Compilerhersteller, oder bei der WinAPI Microsoft überlassen, welchen Wert TRUE hat.<br />
Wenn man aber überprüft, ob etwas ungleich FALSE ist, so ist man immer auf der sicheren Seite.</p>
</blockquote>
<p>Nicht wirklich, oder? Das kann doch nicht sein, dass die solche Fallen einbauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352680</guid><dc:creator><![CDATA[egh]]></dc:creator><pubDate>Mon, 27 Aug 2007 04:39:49 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 07:43:22 GMT]]></title><description><![CDATA[<p>naja, soweit ich weiß, definiert Microsoft TRUE als -1, aber sicher ist halt sicher.</p>
<p>denn wenn du in der MSDN liest, z.B. bei</p>
<pre><code class="language-cpp">BOOL UpdateWindow(
  HWND hWnd   // handle to window
);
</code></pre>
<p>dann liest man da:<br />
If the function succeeds, the return value is <strong>nonzero</strong>.<br />
If the function fails, the return value is zero.</p>
<p>und <strong>nonzero</strong> heißt bei mir ungleich 0 und nicht -1.<br />
also lieber mit FALSE überprüfen, anstatt mit TRUE.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352727</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 27 Aug 2007 07:43:22 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 07:48:05 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>also lieber mit FALSE überprüfen, anstatt mit TRUE.</p>
</blockquote>
<p>Man sollte IMHO diese Konstanten in bool-Ausdrücken gar nicht benutzen.</p>
<pre><code class="language-cpp">if( foo == TRUE )
</code></pre>
<p>ist genauso überflüssig wie</p>
<pre><code class="language-cpp">if( foo != FALSE )
</code></pre>
<p>Einfach nur:</p>
<pre><code class="language-cpp">if( foo )
</code></pre>
<p>-&gt; Fertig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352732</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 27 Aug 2007 07:48:05 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 08:17:56 GMT]]></title><description><![CDATA[<p>ähm, vielleicht hast du übersehen, dass es keine <strong>bool</strong>-Ausdrücke sind,<br />
sondern <strong>BOOL</strong>-Ausdrücke, und <strong>BOOL</strong> ist von Microsoft als <strong>int</strong> definiert.</p>
<p>deshalb kann man BOOL auch nich einfach zu bool casten.<br />
jedenfalls nicht ohne den Hinweis auf einen Datenverlust...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352742</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 27 Aug 2007 08:17:56 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 08:35:06 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>ähm, vielleicht hast du übersehen, dass es keine <strong>bool</strong>-Ausdrücke sind,<br />
sondern <strong>BOOL</strong>-Ausdrücke, und <strong>BOOL</strong> ist von Microsoft als <strong>int</strong> definiert.</p>
</blockquote>
<p>Nein, das habe ich nicht übersehen.</p>
<blockquote>
<p>deshalb kann man BOOL auch nich einfach zu bool casten.<br />
jedenfalls nicht ohne den Hinweis auf einen Datenverlust...</p>
</blockquote>
<p>Die Verwendung eines int-Ausdrucks in einer if-Anweisung erzeugt bei keinem mir bekannten Compiler einen &quot;Hinweis auf einen Datenverlust&quot;. Hast du ein Beispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352753</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 27 Aug 2007 08:35:06 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 08:41:35 GMT]]></title><description><![CDATA[<p>ja, in diesem Fall geht es^^</p>
<p>der Hinweis sollte kommen bei bei</p>
<pre><code class="language-cpp">BOOL x = TRUE;
bool y = (bool)x;
</code></pre>
<p>im Endeffekt geht das trotzdem, aber halt Warnung...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352756</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 27 Aug 2007 08:41:35 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 08:45:42 GMT]]></title><description><![CDATA[<p>Nein! Auch in diesem Fall kommt keine Warnung. Denn Du führst einen cast aus. Un der cast von int auf bool ürt nichts anderes aus als ein das Ergebnis von x!=0 zu setzen.</p>
<p>Eine Warnung kommt nur, wenn Du du Zuweisung ohne cast ausführst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352759</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 27 Aug 2007 08:45:42 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 08:49:28 GMT]]></title><description><![CDATA[<p>Martin Richter schrieb:</p>
<blockquote>
<p>Eine Warnung kommt nur, wenn Du du Zuweisung ohne cast ausführst.</p>
</blockquote>
<p>C4800 kommt auch bei einem Cast:</p>
<p>MSDN Library schrieb:</p>
<blockquote>
<p>Casting the expression to type bool will not disable the warning, which is by design.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1352762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352762</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 27 Aug 2007 08:49:28 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Mon, 27 Aug 2007 10:38:25 GMT]]></title><description><![CDATA[<p>Upps...<br />
Ja es kommt eine Warnung, aberist ist keine Warnung über Datenverlust! Es ist eine Performance Warnung!</p>
<p>Aber Ok! Ganz korrekt war meine Antwort nicht.</p>
<p>Dann ist der korrekte Weg einzig und alleine</p>
<pre><code class="language-cpp">BOOL x = TRUE;
bool y = x!=0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1352868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352868</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 27 Aug 2007 10:38:25 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 07:19:30 GMT]]></title><description><![CDATA[<p>Jedenfalls funktioniert es bei mir nun ordentlich; wegen der Prüfung, müsste mal jedes Szenario ausprobieren.<br />
Gibt es eine andere Möglichkeit auf den Dateinamen zuzugreifen als ofn.lpstrFile ?</p>
<p>Vielen Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1353500</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1353500</guid><dc:creator><![CDATA[Funktioniert nun]]></dc:creator><pubDate>Tue, 28 Aug 2007 07:19:30 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 07:46:58 GMT]]></title><description><![CDATA[<p>Was meinst Du mit andere Möglichkeiten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1353527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1353527</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 28 Aug 2007 07:46:58 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 13:24:23 GMT]]></title><description><![CDATA[<p>Anstelle z.B. MessageBox (ofn.lp..... ...) den namen in einem normalen Char oder string zu haben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1353843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1353843</guid><dc:creator><![CDATA[APIAnfaenger]]></dc:creator><pubDate>Tue, 28 Aug 2007 13:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 14:17:57 GMT]]></title><description><![CDATA[<p>lpstrFile ist ein normaler TCHAR*, was möchtest Du mehr?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1353882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1353882</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 28 Aug 2007 14:17:57 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 19:14:48 GMT]]></title><description><![CDATA[<p>Ja ein Zeiger oder irre ich mich da? Den Wert in einrm &quot;normalen&quot; char, nicht als Zeiger</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1354077</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1354077</guid><dc:creator><![CDATA[APIAnfaenger]]></dc:creator><pubDate>Tue, 28 Aug 2007 19:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Tue, 28 Aug 2007 19:54:29 GMT]]></title><description><![CDATA[<p>APIAnfaenger schrieb:</p>
<blockquote>
<p>Ja ein Zeiger oder irre ich mich da? Den Wert in einrm &quot;normalen&quot; char, nicht als Zeiger</p>
</blockquote>
<p>Es ist ein Zeiger! TCHAR ist entweder char oder wchar_t je nach Zeichensatz.<br />
BTW:</p>
<p>DrakoXP schrieb:</p>
<blockquote>
<p>TRUE ist jedoch != 0 und damit undefiniert.</p>
</blockquote>
<p>Natürlich ist TRUE definiert und zwar als 1 -sinnigerweise.</p>
<p>DrakoXP schrieb:</p>
<blockquote>
<p>Es ist somit dem Compilerhersteller, oder bei der WinAPI Microsoft überlassen, welchen Wert TRUE hat.</p>
</blockquote>
<p>Ein Compilerhersteller hat damit wenig zu tun, da diese nicht im Compiler (bzw. in der entsprechenden Sprache) verankert sind, im Gegensatz zu (bspw.) true oder false. Damit ist es also nur Microsoft überlassen, welchen Wert diese Konstanten wirklich haben, und der steht in den Headern.<br />
q.e.d.:</p>
<p>windef.h [WinApi-Standardheader] schrieb:</p>
<blockquote>
<p>// ...</p>
<pre><code class="language-cpp">#ifndef FALSE
#define FALSE               0
#endif

#ifndef TRUE
#define TRUE                1
#endif
</code></pre>
<p>// ...</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1354116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1354116</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 28 Aug 2007 19:54:29 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Wed, 29 Aug 2007 06:28:07 GMT]]></title><description><![CDATA[<p>Soweit ich den Standard im Kopf habe ist das Ergebnis von 1==1 definiert als true, 1!=0 als false. Weißt man ein boolsches Ergebnis einer int Variable zu ist dies definiert als 1 oder 0.</p>
<p>Richtig ist, dass die interne Darstellung eines bool Datatypes dem Compilerhersteller überlassen ist.<br />
Die Zuweisung in einen int ist keineswegs undefiniert.<br />
Insofern ist es nur zu logisch 0 als FALSE und 1 als TRUE zu definieren.</p>
<p>Unterscheiden muss man dennoch die Nutzung des Datentypes BOOL in der WinAPI. Hier gilt nur folgendes hat ein BOOL Typ den Wert 0, heißt dies false. !=0 bedeutet false. Man kann aber eben nicht mit Sicherheit sagen, dass TRUE returniert wird. Die Ergebnisse 5, 1234 und so weiter würden ebenfalls true signalisieren.<br />
Der Vergleich eines BOOL Wertes mit TRUE führt also nicht unbedingt zum gewünschten Ergebnis. Der Vergleich eines BOOL Wertes mit FALSE dagegen schon...</p>
<p>Ich hoffe das ist verständlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1354278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1354278</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Wed, 29 Aug 2007 06:28:07 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Wed, 29 Aug 2007 15:20:57 GMT]]></title><description><![CDATA[<p>Martin Richter schrieb:</p>
<blockquote>
<p>[...]<br />
Ich hoffe das ist verständlich.</p>
</blockquote>
<p>Joar klaro <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> . Damit sollte man damit doch auf der richtigen Seite sein:</p>
<pre><code class="language-cpp">BOOL bSuccess = IrgendEineFunktionDieBOOLZurueckGibt();
if(bSuccess)
  // Erfolgreich...
else
  // Aua...
</code></pre>
<p>(Bereits von MFK gepostet; diese Prüfung bevorzuge ich nämlich auch.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1354688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1354688</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Wed, 29 Aug 2007 15:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to Oeffnen-Dialog erscheint nicht on Wed, 29 Aug 2007 16:31:42 GMT]]></title><description><![CDATA[<p>Und man kann es auch wirklich wörtlich einfach lesen...</p>
<pre><code class="language-cpp">if (bSuccess) // Wenn erfolgreich
...
if (!bSuccess) // Wenn nicht erfolgreich
...
</code></pre>
<p>alle != und == Operatoren an dieser Stelle empfinde ich persönlich als verwirrend.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1354722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1354722</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Wed, 29 Aug 2007 16:31:42 GMT</pubDate></item></channel></rss>