<?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[anfänger braucht h.i.l.f.e.]]></title><description><![CDATA[<p>ich lerne langsam windows-programmierung. da ich gerne an beispielen lerne, hat mir ein kumpel das folgende programm trocken erklärt - wie wo weshalb und warum - jedoch kriege ich eine Fehlermeldung, wenn ich das Programm mit Microsoft Visual C++ ans Laufen kriegen will:</p>
<p>*: error C2664: 'DialogBoxParamA' : Konvertierung des Parameters 4 von 'int (__stdcall *)(void)' in 'int (__stdcall *)(struct HWND__ <em>,unsigned int,unsigned int,long)' nicht moe<br />
glich<br />
Diese Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat</em></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

HINSTANCE Instanz;
COLORREF kreis1;
COLORREF kreis2;
const COLORREF k1def=RGB(255,255,255);
const COLORREF k2def=RGB(255,0,0);

HPEN hp;
HPEN hp2;
HWND MWIN;
int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
LONG FAR PASCAL Fensterfunktion(HWND,UINT,WPARAM,LPARAM);
BOOL FAR PASCAL DialogFunktion(HWND,UINT,WPARAM,LPARAM);

int PASCAL WinMain(HINSTANCE di,HINSTANCE vi,LPSTR Komm,int Ftype){
  MSG Messy;

  Instanz=di;
  if(!vi){
    WNDCLASS wc;
    wc.style=CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc=Fensterfunktion;
    wc.cbClsExtra=0;
    wc.cbWndExtra=0;
    wc.hInstance=di;
    wc.hIcon=0;
    wc.hCursor=LoadIcon(NULL,NULL);;
    wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
    wc.lpszMenuName=&quot;SimpelMenue&quot;;
    wc.lpszClassName=&quot;Einfach&quot;;
    if(!RegisterClass(&amp;wc)) return 255;
  }
  MWIN=CreateWindow(&quot;Einfach&quot;,&quot;Das Spiel mit den Farben&quot;,WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT,CW_USEDEFAULT,
  CW_USEDEFAULT,CW_USEDEFAULT,
  NULL,NULL,di,NULL);
  if(!MWIN)return 255;
  ShowWindow(MWIN,Ftype);
  UpdateWindow(MWIN);
  while(GetMessage(&amp;Messy,0,0,0)){
    TranslateMessage(&amp;Messy);
    DispatchMessage(&amp;Messy);
  }
  return Messy.wParam;
}
BOOL FAR PASCAL DialogFunktion(HWND fenster,UINT nachricht,WPARAM p1,LPARAM p2){
  switch (nachricht){
     case WM_INITDIALOG:
             MessageBeep(0);
             SetDlgItemInt(fenster,101,GetRValue(kreis1),false);
             SetDlgItemInt(fenster,102,GetGValue(kreis1),false);
             SetDlgItemInt(fenster,103,GetBValue(kreis1),false);
             SetDlgItemInt(fenster,104,GetRValue(kreis2),false);
             SetDlgItemInt(fenster,105,GetGValue(kreis2),false);
             SetDlgItemInt(fenster,106,GetBValue(kreis2),false);

          break;
     case WM_COMMAND:

          switch(p1){
             case IDOK:
             int r,g,b;
             int ok=1;
             r=GetDlgItemInt(fenster,101,&amp;ok,false);
             g=GetDlgItemInt(fenster,102,&amp;ok,false);
             b=GetDlgItemInt(fenster,103,&amp;ok,false);
             kreis1=RGB(r,g,b);
             hp=CreatePen(PS_SOLID,2,kreis1);
             r=GetDlgItemInt(fenster,104,&amp;ok,false);
             g=GetDlgItemInt(fenster,105,&amp;ok,false);
             b=GetDlgItemInt(fenster,106,&amp;ok,false);
             kreis2=RGB(r,g,b);
             hp2=CreatePen(PS_SOLID,2,kreis2);
             InvalidateRect(MWIN,NULL,false);

             EndDialog(fenster,0);

          }
     break;
  }
  return DefWindowProc(fenster,nachricht,p1,p2);
}
LONG FAR PASCAL Fensterfunktion(HWND fenster,UINT nachricht,WPARAM p1,LPARAM p2){
  HDC hdc;
  PAINTSTRUCT ps;
  static RECT re;
  static int r1=50; //r1&gt;r2
  static int r2=40;
  static int r1b=51; //r1&gt;r2
  static int r2b=41;
  static int r1bi=49; //r1&gt;r2
  static int r2bi=39;

  static int offs=80;
  const char mytext[57] = &quot;Hallo, dies ist ein Text, falls sie's noch nicht wussten&quot;;
  static int textlen=56;
  static FARPROC DialogZeiger;
  static HPEN hpb;
  static HPEN hp2b;
  COLORREF hlp;
  int he;
  static HBRUSH hb;
  switch (nachricht){
    case WM_RBUTTONDOWN:
                 kreis1=k1def;
                 kreis2=k2def;
                 hp=CreatePen(PS_SOLID,2,kreis1);
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
    break;
    case WM_CHAR:
             switch (p1){
                case 'r':
                 he=GetRValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(he,GetGValue(kreis2),GetBValue(kreis2));
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;
                case 'g':
                 he=GetGValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(GetRValue(kreis2),he,GetBValue(kreis2));
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;
                case 'b':
                 he=GetBValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(GetRValue(kreis2),GetGValue(kreis2),he);
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;

             }
        return 0;
    break;
    case WM_PAINT:

                  hdc=BeginPaint(fenster,&amp;ps);

                  SetBkMode(hdc, TRANSPARENT);

                  SetTextColor(hdc,RGB(0,0,255));

                  SelectObject(hdc,hb);
                  SelectObject(hdc,hpb);
  						Ellipse(hdc,(re.right/2)-r1b,(re.bottom/2)-r1b+offs,(re.right/2)+r1b,(re.bottom/2)+r1b+offs);
                  SelectObject(hdc,hp);
						Ellipse(hdc,(re.right/2)-r1,(re.bottom/2)-r1+offs,(re.right/2)+r1,(re.bottom/2)+r1+offs);
                  SelectObject(hdc,hpb);
  						Ellipse(hdc,(re.right/2)-r1bi,(re.bottom/2)-r1bi+offs,(re.right/2)+r1bi,(re.bottom/2)+r1bi+offs);

                  SelectObject(hdc,hp2b);
 						Ellipse(hdc,(re.right/2)-r2b,(re.bottom/2)-r2b+offs,(re.right/2)+r2b,(re.bottom/2)+r2b+offs);
                  SelectObject(hdc,hp2);
 						Ellipse(hdc,(re.right/2)-r2,(re.bottom/2)-r2+offs,(re.right/2)+r2,(re.bottom/2)+r2+offs);
                  SelectObject(hdc,hp2b);
 						Ellipse(hdc,(re.right/2)-r2bi,(re.bottom/2)-r2bi+offs,(re.right/2)+r2bi,(re.bottom/2)+r2bi+offs);

                  TextOut(hdc,(re.right/2)-170,re.bottom/2,mytext,textlen);
                  EndPaint(fenster,&amp;ps);
                  return 0;
    case WM_CREATE: 
                    DialogZeiger=MakeProcInstance((FARPROC) DialogFunktion, Instanz);
                    kreis1=k1def;//RGB(255,255,255);
                    kreis2=k2def;//RGB(255,0,0);
                    hp=CreatePen(PS_SOLID,2,kreis1);
                    hp2=CreatePen(PS_SOLID,2,kreis2);
                    hpb=CreatePen(PS_DOT,1,RGB(0,0,0));
                    hp2b=CreatePen(PS_DASHDOT,1,RGB(255,255,255));

                    hb=CreateSolidBrush(RGB(128,128,128));
                                      GetClientRect(fenster,&amp;re);

                    return 0;
    case WM_COMMAND: switch(p1){
    			  case 11: DialogBox(Instanz,&quot;Farben&quot;,fenster,DialogZeiger);
              return 0;
              case 12: SendMessage(fenster,WM_CLOSE,0,0L);return 0;
              break;
    }
    case WM_LBUTTONDOWN:
                 hlp=kreis1;
                 kreis1=kreis2;
                 kreis2=hlp;
                 hp=CreatePen(PS_SOLID,2,kreis1);
                 hp2=CreatePen(PS_SOLID,2,kreis2);

                 InvalidateRect(fenster,NULL,FALSE);

                 return 0;
              break;
    case WM_DESTROY:PostQuitMessage(0);
                    return 0;
    case WM_WINDOWPOSCHANGING:
                     InvalidateRect(fenster,NULL,true);    break;
  }
  return DefWindowProc(fenster,nachricht,p1,p2);
}
</code></pre>
<p>hoffe und danke für hilfe ....</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145788/anfänger-braucht-h-i-l-f-e</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 05:50:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145788.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 May 2006 12:45:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to anfänger braucht h.i.l.f.e. on Mon, 01 May 2006 12:45:08 GMT]]></title><description><![CDATA[<p>ich lerne langsam windows-programmierung. da ich gerne an beispielen lerne, hat mir ein kumpel das folgende programm trocken erklärt - wie wo weshalb und warum - jedoch kriege ich eine Fehlermeldung, wenn ich das Programm mit Microsoft Visual C++ ans Laufen kriegen will:</p>
<p>*: error C2664: 'DialogBoxParamA' : Konvertierung des Parameters 4 von 'int (__stdcall *)(void)' in 'int (__stdcall *)(struct HWND__ <em>,unsigned int,unsigned int,long)' nicht moe<br />
glich<br />
Diese Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat</em></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

HINSTANCE Instanz;
COLORREF kreis1;
COLORREF kreis2;
const COLORREF k1def=RGB(255,255,255);
const COLORREF k2def=RGB(255,0,0);

HPEN hp;
HPEN hp2;
HWND MWIN;
int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
LONG FAR PASCAL Fensterfunktion(HWND,UINT,WPARAM,LPARAM);
BOOL FAR PASCAL DialogFunktion(HWND,UINT,WPARAM,LPARAM);

int PASCAL WinMain(HINSTANCE di,HINSTANCE vi,LPSTR Komm,int Ftype){
  MSG Messy;

  Instanz=di;
  if(!vi){
    WNDCLASS wc;
    wc.style=CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc=Fensterfunktion;
    wc.cbClsExtra=0;
    wc.cbWndExtra=0;
    wc.hInstance=di;
    wc.hIcon=0;
    wc.hCursor=LoadIcon(NULL,NULL);;
    wc.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
    wc.lpszMenuName=&quot;SimpelMenue&quot;;
    wc.lpszClassName=&quot;Einfach&quot;;
    if(!RegisterClass(&amp;wc)) return 255;
  }
  MWIN=CreateWindow(&quot;Einfach&quot;,&quot;Das Spiel mit den Farben&quot;,WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT,CW_USEDEFAULT,
  CW_USEDEFAULT,CW_USEDEFAULT,
  NULL,NULL,di,NULL);
  if(!MWIN)return 255;
  ShowWindow(MWIN,Ftype);
  UpdateWindow(MWIN);
  while(GetMessage(&amp;Messy,0,0,0)){
    TranslateMessage(&amp;Messy);
    DispatchMessage(&amp;Messy);
  }
  return Messy.wParam;
}
BOOL FAR PASCAL DialogFunktion(HWND fenster,UINT nachricht,WPARAM p1,LPARAM p2){
  switch (nachricht){
     case WM_INITDIALOG:
             MessageBeep(0);
             SetDlgItemInt(fenster,101,GetRValue(kreis1),false);
             SetDlgItemInt(fenster,102,GetGValue(kreis1),false);
             SetDlgItemInt(fenster,103,GetBValue(kreis1),false);
             SetDlgItemInt(fenster,104,GetRValue(kreis2),false);
             SetDlgItemInt(fenster,105,GetGValue(kreis2),false);
             SetDlgItemInt(fenster,106,GetBValue(kreis2),false);

          break;
     case WM_COMMAND:

          switch(p1){
             case IDOK:
             int r,g,b;
             int ok=1;
             r=GetDlgItemInt(fenster,101,&amp;ok,false);
             g=GetDlgItemInt(fenster,102,&amp;ok,false);
             b=GetDlgItemInt(fenster,103,&amp;ok,false);
             kreis1=RGB(r,g,b);
             hp=CreatePen(PS_SOLID,2,kreis1);
             r=GetDlgItemInt(fenster,104,&amp;ok,false);
             g=GetDlgItemInt(fenster,105,&amp;ok,false);
             b=GetDlgItemInt(fenster,106,&amp;ok,false);
             kreis2=RGB(r,g,b);
             hp2=CreatePen(PS_SOLID,2,kreis2);
             InvalidateRect(MWIN,NULL,false);

             EndDialog(fenster,0);

          }
     break;
  }
  return DefWindowProc(fenster,nachricht,p1,p2);
}
LONG FAR PASCAL Fensterfunktion(HWND fenster,UINT nachricht,WPARAM p1,LPARAM p2){
  HDC hdc;
  PAINTSTRUCT ps;
  static RECT re;
  static int r1=50; //r1&gt;r2
  static int r2=40;
  static int r1b=51; //r1&gt;r2
  static int r2b=41;
  static int r1bi=49; //r1&gt;r2
  static int r2bi=39;

  static int offs=80;
  const char mytext[57] = &quot;Hallo, dies ist ein Text, falls sie's noch nicht wussten&quot;;
  static int textlen=56;
  static FARPROC DialogZeiger;
  static HPEN hpb;
  static HPEN hp2b;
  COLORREF hlp;
  int he;
  static HBRUSH hb;
  switch (nachricht){
    case WM_RBUTTONDOWN:
                 kreis1=k1def;
                 kreis2=k2def;
                 hp=CreatePen(PS_SOLID,2,kreis1);
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
    break;
    case WM_CHAR:
             switch (p1){
                case 'r':
                 he=GetRValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(he,GetGValue(kreis2),GetBValue(kreis2));
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;
                case 'g':
                 he=GetGValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(GetRValue(kreis2),he,GetBValue(kreis2));
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;
                case 'b':
                 he=GetBValue(kreis2)+1;
                 if (he&gt;255)he=255;
                 kreis2=RGB(GetRValue(kreis2),GetGValue(kreis2),he);
                 hp2=CreatePen(PS_SOLID,2,kreis2);
                 InvalidateRect(fenster,NULL,false);
                return 0;

             }
        return 0;
    break;
    case WM_PAINT:

                  hdc=BeginPaint(fenster,&amp;ps);

                  SetBkMode(hdc, TRANSPARENT);

                  SetTextColor(hdc,RGB(0,0,255));

                  SelectObject(hdc,hb);
                  SelectObject(hdc,hpb);
  						Ellipse(hdc,(re.right/2)-r1b,(re.bottom/2)-r1b+offs,(re.right/2)+r1b,(re.bottom/2)+r1b+offs);
                  SelectObject(hdc,hp);
						Ellipse(hdc,(re.right/2)-r1,(re.bottom/2)-r1+offs,(re.right/2)+r1,(re.bottom/2)+r1+offs);
                  SelectObject(hdc,hpb);
  						Ellipse(hdc,(re.right/2)-r1bi,(re.bottom/2)-r1bi+offs,(re.right/2)+r1bi,(re.bottom/2)+r1bi+offs);

                  SelectObject(hdc,hp2b);
 						Ellipse(hdc,(re.right/2)-r2b,(re.bottom/2)-r2b+offs,(re.right/2)+r2b,(re.bottom/2)+r2b+offs);
                  SelectObject(hdc,hp2);
 						Ellipse(hdc,(re.right/2)-r2,(re.bottom/2)-r2+offs,(re.right/2)+r2,(re.bottom/2)+r2+offs);
                  SelectObject(hdc,hp2b);
 						Ellipse(hdc,(re.right/2)-r2bi,(re.bottom/2)-r2bi+offs,(re.right/2)+r2bi,(re.bottom/2)+r2bi+offs);

                  TextOut(hdc,(re.right/2)-170,re.bottom/2,mytext,textlen);
                  EndPaint(fenster,&amp;ps);
                  return 0;
    case WM_CREATE: 
                    DialogZeiger=MakeProcInstance((FARPROC) DialogFunktion, Instanz);
                    kreis1=k1def;//RGB(255,255,255);
                    kreis2=k2def;//RGB(255,0,0);
                    hp=CreatePen(PS_SOLID,2,kreis1);
                    hp2=CreatePen(PS_SOLID,2,kreis2);
                    hpb=CreatePen(PS_DOT,1,RGB(0,0,0));
                    hp2b=CreatePen(PS_DASHDOT,1,RGB(255,255,255));

                    hb=CreateSolidBrush(RGB(128,128,128));
                                      GetClientRect(fenster,&amp;re);

                    return 0;
    case WM_COMMAND: switch(p1){
    			  case 11: DialogBox(Instanz,&quot;Farben&quot;,fenster,DialogZeiger);
              return 0;
              case 12: SendMessage(fenster,WM_CLOSE,0,0L);return 0;
              break;
    }
    case WM_LBUTTONDOWN:
                 hlp=kreis1;
                 kreis1=kreis2;
                 kreis2=hlp;
                 hp=CreatePen(PS_SOLID,2,kreis1);
                 hp2=CreatePen(PS_SOLID,2,kreis2);

                 InvalidateRect(fenster,NULL,FALSE);

                 return 0;
              break;
    case WM_DESTROY:PostQuitMessage(0);
                    return 0;
    case WM_WINDOWPOSCHANGING:
                     InvalidateRect(fenster,NULL,true);    break;
  }
  return DefWindowProc(fenster,nachricht,p1,p2);
}
</code></pre>
<p>hoffe und danke für hilfe ....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048915</guid><dc:creator><![CDATA[unwissend]]></dc:creator><pubDate>Mon, 01 May 2006 12:45:08 GMT</pubDate></item><item><title><![CDATA[Reply to anfänger braucht h.i.l.f.e. on Mon, 01 May 2006 13:04:41 GMT]]></title><description><![CDATA[<p>Dein Problem ist, dass du zwei verschiedene Arten von Variabeln hast. Vollgender Code funktioniert bekantlich nicht:</p>
<pre><code class="language-cpp">int x = 10;
cMeineKlasse Object2; // Eine selbstentwickelte Klasse
Object2.Verarbeiten();
x = Object2;
</code></pre>
<p>Genau das macht jedoch dein Code. Mit der folgenden Änderung in deinem Code sollte es funktionieren:</p>
<pre><code class="language-cpp">case 11: DialogBox(Instanz,&quot;Farben&quot;,fenster,(DLGPROC)DialogZeiger);
</code></pre>
<p>Jedoch ist noch die Frage offen, ob das &quot;sauber&quot; ist. (Den Code habe ich nicht studiert)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1048930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1048930</guid><dc:creator><![CDATA[black_sheep_thomas]]></dc:creator><pubDate>Mon, 01 May 2006 13:04:41 GMT</pubDate></item></channel></rss>