Hypercell ein ] Hypercell aus ] Zeige Navigation ] Verstecke Navigation ]
c++.de  
   
Forentreff 2012     
Bücher-Shop mit Amazon (Buchkategorien)C++ : Referenzen zu C++ : C++ Builder : Visual C++ : C# : Java : Spieleprogrammierung : Systemprogrammierung Linux : Software-Entwicklung : .NET : Compilertechnik : Algorithmen & Datenstrukturen : Objektorientierung : Entwurfsmuster : UML : eXtreme Programming : Scrum : Projektmanagement : Software-Testing : Datenbanken : Tom DeMarco : Dilbert : User Friendly
C/C++ Forum :: FAQ - WinAPI ::  Inputbox (oder allg. Dialoge ohne Resourcen)     Zeige alle Beiträge auf einer Seite Auf Beitrag antworten
Autor Nachricht
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 10:40:00 14.11.2002   Titel:   Inputbox (oder allg. Dialoge ohne Resourcen)            Zitieren

Hallo,

ich bins mal wieder,
wie kann ich eine messagebox mit eingabefeld machen, die eine INT-zahl speichert???
Ist das eingegebene dann gleich 'ne zahl oder wird dass als string angesehen (oder char?) ??


edit: Titel geändert.

[ Dieser Beitrag wurde am 17.11.2002 um 16:13 Uhr von cd9000 editiert. ]
Werbeunterbrechung
PeterTheMaster
Mitglied

Benutzerprofil
Anmeldungsdatum: 31.08.2002
Beiträge: 2120
Beitrag PeterTheMaster Mitglied 12:02:00 14.11.2002   Titel:              Zitieren

woher soll einer wissen, was fuer eine box du nimmst? ab nach mfc oder winapi oder so.

_________________
jedem das seine.
Gerard
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.01.2002
Beiträge: 6119
Beitrag Gerard Mitglied 12:55:00 14.11.2002   Titel:              Zitieren

Zitat:
Original erstellt von PeterTheMaster:
ab nach mfc oder winapi oder so.

sag nicht so, das hört sich an als ob der da noch mal posten soll, wir verschieben lieber die Threads!

@Netspider in welches Forum soll der Thread verschoben werden?
Wohin mit meiner Frage?
lane
Mitglied

Benutzerprofil
Anmeldungsdatum: 15.10.2002
Beiträge: 28
Beitrag lane Mitglied 15:23:00 14.11.2002   Titel:              Zitieren

LLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOOOOOLLLLLLLLLLLLLLLLL :D :) .

wuerde es dir was ausmachen zu sagen
-mit welcher klassenbibliothek
-unter welchem betriebssystem
du das programmieren willst?

_________________
c++ anfaenger, bitte nicht schlagen :)
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 18:19:00 14.11.2002   Titel:              Zitieren

öööh, windows, VC++
ich dachte es gibt einen einfachen befehl mit dem man eine eingabe
des benutzers machen kann, muss das verschoben werden?????
ich verstehe nicht wieso das nicht hier reinpassen soll!

erst schreibe ich einen beitrag in das MFC forum und der wird sofort von euch gesperrt *grrr*
dann schreib ich hier rein und ihr meckert wieder !!!!!

[edit]hier ist mal ein beispiel, wie es aussehen soll,
für die, die noch nicht wissen, was ich meine.
einfach den link in ein browserfenster kopieren und starten
[java]
javascript:window.prompt('Testbox','test')[/code]
[/edit]

[ Dieser Beitrag wurde am 14.11.2002 um 17:43 Uhr von Netspider editiert. ]
PeterTheMaster
Mitglied

Benutzerprofil
Anmeldungsdatum: 31.08.2002
Beiträge: 2120
Beitrag PeterTheMaster Mitglied 19:03:00 14.11.2002   Titel:              Zitieren

sowas ist mit standard c++ definitiv nicht zu erreichen. wenn es dir nur auf die eingabe, nicht das fensterchen ankommt, dann kannst dus ueber die konsole machen.
lies mal was ueber cin und cout.

_________________
jedem das seine.
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 19:07:00 14.11.2002   Titel:              Zitieren

naja, ich wusel so ein bisschen in Opengl rum und wollte aber vom user noch eine zahl abfragen, bevor das programm richtig startet, also mit windows und VC++, OpenGL und wenig ahnung ;-)

aber ein NIMM-Spiel habe icch schon hinbekommen *g*
- 21 streichhölzer am anfang, man nimmt immer 1-3, dann comp, wer das letzt zieht hat verloren *bg* -
Gerard
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.01.2002
Beiträge: 6119
Beitrag Gerard Mitglied 19:23:00 14.11.2002   Titel:              Zitieren

Ich verscheibe den Thread ins WinAPI Forum.
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 02:00:00 15.11.2002   Titel:              Zitieren

Da musst du dir wohl oder übel einen eigenen Dialog basteln.

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 08:21:00 15.11.2002   Titel:              Zitieren

...oder WebFritzi arbeiten lassen. ;) Ich habe jetzt die ganze Nacht durchgearbeitet, um diesen dummen Dialog zu basteln (ohne Resource). Dabei ist folgende cpp-Datei herausgekommen ([edit]überarbeitete Version[/edit]):
C/C++ Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
Die zur cpp-Datei gehörige Header-Datei (*.h)
----------------------------------------------

//---------------------------------------------------------------------------
#ifndef
DynDialogsH
#define
DynDialogsH
//---------------------------------------------------------------------------
#include
<windows.h>
//---------------------------------------------------------------------------

// Input-Box-Childs

#define
 ID_INPUT     200
#define
 ID_INFOTEXT  201

// Control Classes
#define
 BUTTON_CLASS       0x0080
#define
 EDIT_CLASS         0x0081
#define
 STATIC_CLASS       0x0082
#define
 LISTBOX_CLASS      0x0083
#define
 SCROLLBAR_CLASS    0x0084
#define
 COMBOBOX_CLASS     0x0085

// Definitions of icon representations in ShowMessage()
#define
 SM_NONE       0
#define
 SM_WARNING    1
#define
 SM_INFO       2
#define
 SM_ERROR      3
//---------------------------------------------------------------------------

LPWORD          DWORD_ALIGN(LPWORD);
LPWORD          NON_DWORD_ALIGN(LPWORD);
LPWORD          InitDialog(LPVOID, LPCTSTR, DWORD, WORD, LPCTSTR, WORD, short, short, short, short);
LPWORD          CreateDlgControl(LPWORD, WORD, WORD, LPCTSTR, DWORD, short, short, short, short);
int             InputBox(HWND, LPCTSTR, LPCTSTR, LPTSTR, INT);
VOID            ShowMessage(HWND, LPCTSTR, LPCTSTR, WORD);
BOOL  CALLBACK  InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
#endif





Die cpp-Datei
--------------

//---------------------------------------------------------------------------
#include
"DynDialogs.h"
//---------------------------------------------------------------------------

LPWORD DWORD_ALIGN(LPWORD lpIn)
{
   ULONG ul = (ULONG)lpIn;

   ul += 3;
   ul >>= 2;
   ul <<= 2;

   return (LPWORD)ul;
}
//---------------------------------------------------------------------------

LPWORD NON_DWORD_ALIGN(LPWORD lpIn)
{
   return (DWORD_ALIGN(lpIn - 1) + 1);
}
//---------------------------------------------------------------------------

LPWORD InitDialog(LPVOID lpv, LPCTSTR title, DWORD style, WORD ctrlno, LPCTSTR fontname,
                  WORD fontsize, short x, short y, short cx, short cy)
{
    LPWORD        lpw;
    LPWSTR        lpwsz;
    int           nchar, wcharlength;
    LPDLGTEMPLATE lpdt = (LPDLGTEMPLATE)lpv;

    lpdt->style = style;
    lpdt->dwExtendedStyle = 0;
    lpdt->cdit = ctrlno;
    lpdt->x  = x;  lpdt->y  = y;
    lpdt->cx = cx; lpdt->cy = cy;

    lpw = (LPWORD)(lpdt + 1);

    // No menu
    *lpw = 0;
    lpw++;

    // Predefined dialog box class (by default)
    *lpw = 0;
    lpw++;

    // The title
    lpwsz = (LPWSTR)lpw;
    wcharlength = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, 0);
    nchar = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, wcharlength);
    lpw += nchar;

    // The font used in dialog
    if(style & DS_SETFONT)
    {
       *lpw = 8;
       lpw++;
       lpwsz = (LPWSTR)lpw;
       wcharlength = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, 0);
       nchar = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, wcharlength);
       lpw += nchar;
    }

    return lpw;
}
//---------------------------------------------------------------------------

LPWORD CreateDlgControl(LPWORD lpw, WORD ctrlclass, WORD id, LPCTSTR caption,
                      DWORD style, short x, short y, short cx, short cy)
{
    LPDLGITEMTEMPLATE lpdit;
    LPWSTR            lpwsz;
    int               nchar, wcharlength;

    lpw = DWORD_ALIGN(lpw);
    lpdit = (LPDLGITEMTEMPLATE)lpw;
    lpdit->style = style;
    lpdit->dwExtendedStyle = 0;
    lpdit->x  = x ; lpdit->y  = y;
    lpdit->cx = cx; lpdit->cy = cy;
    lpdit->id = id;

    // class
    lpw = (LPWORD)(lpdit + 1);
    *lpw = 0xFFFF;
    lpw++;
    *lpw = ctrlclass;
    lpw++;

    // title
    lpwsz = (LPWSTR)lpw;
    wcharlength = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, 0);
    nchar = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, wcharlength);
    lpw += nchar;

    // no creation data
    lpw = NON_DWORD_ALIGN(lpw);
    *lpw = 0;
    lpw++;

    return lpw;
}
//---------------------------------------------------------------------------

int InputBox(HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength)
{
    HGLOBAL  hgbl;
    LPWORD   lpw;
    LRESULT  ret;
    DWORD    style;

    hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
    if(!hgbl) return 0;
    LPVOID lpv = GlobalLock(hgbl);

    // Prepare the dialog box
    style = DS_SETFONT | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | WS_VISIBLE;
    lpw = InitDialog(lpv, title, style, 4, "MS Sans Serif", 8, 0, 0, 319, 47);

    // OK-Button
    style = WS_CHILD | WS_VISIBLE | WS_TABSTOP |BS_DEFPUSHBUTTON;
    lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDOK, "OK", style, 264, 7, 48, 15);

    // Cancel-Button
    style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
    lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDCANCEL, "Abbrechen", style, 264, 26, 48, 15);

    // Text to prompt
    style = WS_CHILD | WS_VISIBLE | SS_LEFT;
    lpw = CreateDlgControl(lpw, STATIC_CLASS, ID_INFOTEXT, prompt, style, 10, 9, 129, 16);

    // Edit-Control
    style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP;
    lpw = CreateDlgControl(lpw, EDIT_CLASS, ID_INPUT, "", style, 10, 26, 249, 13);

    GlobalUnlock(hgbl);
    int data[2] = {(int)buffer, buflength};
    ret = DialogBoxIndirectParam(NULL, (LPDLGTEMPLATE)hgbl, hwnd,
                                 (DLGPROC)InputBoxDlgProc, (int)data);
    GlobalFree(hgbl);
    return (ret > 0) ? ret : 0;
}
//---------------------------------------------------------------------------

BOOL CALLBACK InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
   static char* buf;
   static int   buflength;
   static HFONT hFont;

   switch(uiMsg)
   {
      case WM_INITDIALOG:
      {
         int* data = (int*)lParam;
         buf = (char*)data[0];
         buflength = data[1];
         HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
         SetFocus(hEdit);
         break;
      }

      case WM_SETFONT:
         hFont = (HFONT)wParam;
         break;

      case WM_CLOSE:
         EndDialog(hwnd, IDCANCEL);
         DeleteObject(hFont);
         break;

      case WM_COMMAND:
      {
         switch(LOWORD(wParam))
         {
            case IDOK:
            {
               HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
               GetWindowText(hEdit, buf, buflength);
               EndDialog(hwnd, IDOK);
               DeleteObject(hFont);
               break;
            }

            case IDCANCEL:
            {
               EndDialog(hwnd, IDCANCEL);
               break;
            }
         }
      }
   }
   return FALSE;
}
//---------------------------------------------------------------------------

VOID ShowMessage(HWND hwnd, LPCTSTR lpszMsg, LPCTSTR lpszTitle, WORD wIcon)
{
   UINT uType = 0;
   if(wIcon == SM_WARNING)
      uType = MB_ICONWARNING;
   else if(wIcon == SM_INFO)
      uType = MB_ICONINFORMATION;
   else if(wIcon == SM_ERROR)
      uType = MB_ICONERROR;

   MessageBox(hwnd, lpszMsg, lpszTitle, uType);
}
//---------------------------------------------------------------------------
C/C++ Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
Die zur cpp-Datei gehörige Header-Datei (*.h)
----------------------------------------------

//---------------------------------------------------------------------------
#ifndef
DynDialogsH
#define
DynDialogsH
//---------------------------------------------------------------------------
#include
<windows.h>
//---------------------------------------------------------------------------

// Input-Box-Childs

#define
ID_INPUT 200
#define
ID_INFOTEXT 201

// Control Classes
#define
BUTTON_CLASS 0x0080
#define
EDIT_CLASS 0x0081
#define
STATIC_CLASS 0x0082
#define
LISTBOX_CLASS 0x0083
#define
SCROLLBAR_CLASS 0x0084
#define
COMBOBOX_CLASS 0x0085

// Definitions of icon representations in ShowMessage()
#define
SM_NONE 0
#define
SM_WARNING 1
#define
SM_INFO 2
#define
SM_ERROR 3
//---------------------------------------------------------------------------

LPWORD DWORD_ALIGN(LPWORD);
LPWORD NON_DWORD_ALIGN(LPWORD);
LPWORD InitDialog(LPVOID, LPCTSTR, DWORD, WORD, LPCTSTR, WORD, short, short, short, short);
LPWORD CreateDlgControl(LPWORD, WORD, WORD, LPCTSTR, DWORD, short, short, short, short);
int InputBox(HWND, LPCTSTR, LPCTSTR, LPTSTR, INT);
VOID ShowMessage(HWND, LPCTSTR, LPCTSTR, WORD);
BOOL CALLBACK InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
#endif





Die cpp-Datei
--------------

//---------------------------------------------------------------------------
#include
"DynDialogs.h"
//---------------------------------------------------------------------------

LPWORD DWORD_ALIGN(LPWORD lpIn)
{
ULONG ul = (ULONG)lpIn;

ul += 3;
ul >>= 2;
ul <<= 2;

return (LPWORD)ul;
}
//---------------------------------------------------------------------------

LPWORD NON_DWORD_ALIGN(LPWORD lpIn)
{
return (DWORD_ALIGN(lpIn - 1) + 1);
}
//---------------------------------------------------------------------------

LPWORD InitDialog(LPVOID lpv, LPCTSTR title, DWORD style, WORD ctrlno, LPCTSTR fontname,
WORD fontsize, short x, short y, short cx, short cy)
{
LPWORD lpw;
LPWSTR lpwsz;
int nchar, wcharlength;
LPDLGTEMPLATE lpdt = (LPDLGTEMPLATE)lpv;

lpdt->style = style;
lpdt->dwExtendedStyle = 0;
lpdt->cdit = ctrlno;
lpdt->x = x; lpdt->y = y;
lpdt->cx = cx; lpdt->cy = cy;

lpw = (LPWORD)(lpdt + 1);

// No menu
*lpw = 0;
lpw++;

// Predefined dialog box class (by default)
*lpw = 0;
lpw++;

// The title
lpwsz = (LPWSTR)lpw;
wcharlength = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, 0);
nchar = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, wcharlength);
lpw += nchar;

// The font used in dialog
if(style & DS_SETFONT)
{
*lpw = 8;
lpw++;
lpwsz = (LPWSTR)lpw;
wcharlength = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, 0);
nchar = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, wcharlength);
lpw += nchar;
}

return lpw;
}
//---------------------------------------------------------------------------

LPWORD CreateDlgControl(LPWORD lpw, WORD ctrlclass, WORD id, LPCTSTR caption,
DWORD style, short x, short y, short cx, short cy)
{
LPDLGITEMTEMPLATE lpdit;
LPWSTR lpwsz;
int nchar, wcharlength;

lpw = DWORD_ALIGN(lpw);
lpdit = (LPDLGITEMTEMPLATE)lpw;
lpdit->style = style;
lpdit->dwExtendedStyle = 0;
lpdit->x = x ; lpdit->y = y;
lpdit->cx = cx; lpdit->cy = cy;
lpdit->id = id;

// class
lpw = (LPWORD)(lpdit + 1);
*lpw = 0xFFFF;
lpw++;
*lpw = ctrlclass;
lpw++;

// title
lpwsz = (LPWSTR)lpw;
wcharlength = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, 0);
nchar = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, wcharlength);
lpw += nchar;

// no creation data
lpw = NON_DWORD_ALIGN(lpw);
*lpw = 0;
lpw++;

return lpw;
}
//---------------------------------------------------------------------------

int InputBox(HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength)
{
HGLOBAL hgbl;
LPWORD lpw;
LRESULT ret;
DWORD style;

hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
if(!hgbl) return 0;
LPVOID lpv = GlobalLock(hgbl);

// Prepare the dialog box
style = DS_SETFONT | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | WS_VISIBLE;
lpw = InitDialog(lpv, title, style, 4, "MS Sans Serif", 8, 0, 0, 319, 47);

// OK-Button
style = WS_CHILD | WS_VISIBLE | WS_TABSTOP |BS_DEFPUSHBUTTON;
lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDOK, "OK", style, 264, 7, 48, 15);

// Cancel-Button
style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDCANCEL, "Abbrechen", style, 264, 26, 48, 15);

// Text to prompt
style = WS_CHILD | WS_VISIBLE | SS_LEFT;
lpw = CreateDlgControl(lpw, STATIC_CLASS, ID_INFOTEXT, prompt, style, 10, 9, 129, 16);

// Edit-Control
style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP;
lpw = CreateDlgControl(lpw, EDIT_CLASS, ID_INPUT, "", style, 10, 26, 249, 13);

GlobalUnlock(hgbl);
int data[2] = {(int)buffer, buflength};
ret = DialogBoxIndirectParam(NULL, (LPDLGTEMPLATE)hgbl, hwnd,
(DLGPROC)InputBoxDlgProc, (int)data);
GlobalFree(hgbl);
return (ret > 0) ? ret : 0;
}
//---------------------------------------------------------------------------

BOOL CALLBACK InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
static char* buf;
static int buflength;
static HFONT hFont;

switch(uiMsg)
{
case WM_INITDIALOG:
{
int* data = (int*)lParam;
buf = (char*)data[0];
buflength = data[1];
HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
SetFocus(hEdit);
break;
}

case WM_SETFONT:
hFont = (HFONT)wParam;
break;

case WM_CLOSE:
EndDialog(hwnd, IDCANCEL);
DeleteObject(hFont);
break;

case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDOK:
{
HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
GetWindowText(hEdit, buf, buflength);
EndDialog(hwnd, IDOK);
DeleteObject(hFont);
break;
}

case IDCANCEL:
{
EndDialog(hwnd, IDCANCEL);
break;
}
}
}
}
return FALSE;
}
//---------------------------------------------------------------------------

VOID ShowMessage(HWND hwnd, LPCTSTR lpszMsg, LPCTSTR lpszTitle, WORD wIcon)
{
UINT uType = 0;
if(wIcon == SM_WARNING)
uType = MB_ICONWARNING;
else if(wIcon == SM_INFO)
uType = MB_ICONINFORMATION;
else if(wIcon == SM_ERROR)
uType = MB_ICONERROR;

MessageBox(hwnd, lpszMsg, lpszTitle, uType);
}
//---------------------------------------------------------------------------
C/C++ Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
Die zur cpp-Datei gehörige Header-Datei (*.h)
----------------------------------------------

//---------------------------------------------------------------------------
#ifndef
DynDialogsH
#define
DynDialogsH
//---------------------------------------------------------------------------
#include
<windows.h>
//---------------------------------------------------------------------------

// Input-Box-Childs

#define
 ID_INPUT     200
#define
 ID_INFOTEXT  201

// Control Classes
#define
 BUTTON_CLASS       0x0080
#define
 EDIT_CLASS         0x0081
#define
 STATIC_CLASS       0x0082
#define
 LISTBOX_CLASS      0x0083
#define
 SCROLLBAR_CLASS    0x0084
#define
 COMBOBOX_CLASS     0x0085

// Definitions of icon representations in ShowMessage()
#define
 SM_NONE       0
#define
 SM_WARNING    1
#define
 SM_INFO       2
#define
 SM_ERROR      3
//---------------------------------------------------------------------------

LPWORD          DWORD_ALIGN(LPWORD);
LPWORD          NON_DWORD_ALIGN(LPWORD);
LPWORD          InitDialog(LPVOID, LPCTSTR, DWORD, WORD, LPCTSTR, WORD, short, short, short, short);
LPWORD          CreateDlgControl(LPWORD, WORD, WORD, LPCTSTR, DWORD, short, short, short, short);
int             InputBox(HWND, LPCTSTR, LPCTSTR, LPTSTR, INT);
VOID            ShowMessage(HWND, LPCTSTR, LPCTSTR, WORD);
BOOL  CALLBACK  InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
#endif





Die cpp-Datei
--------------

//---------------------------------------------------------------------------
#include
"DynDialogs.h"
//---------------------------------------------------------------------------

LPWORD DWORD_ALIGN(LPWORD lpIn)
{
   ULONG ul = (ULONG)lpIn;

   ul += 3;
   ul >>= 2;
   ul <<= 2;

   return (LPWORD)ul;
}
//---------------------------------------------------------------------------

LPWORD NON_DWORD_ALIGN(LPWORD lpIn)
{
   return (DWORD_ALIGN(lpIn - 1) + 1);
}
//---------------------------------------------------------------------------

LPWORD InitDialog(LPVOID lpv, LPCTSTR title, DWORD style, WORD ctrlno, LPCTSTR fontname,
                  WORD fontsize, short x, short y, short cx, short cy)
{
    LPWORD        lpw;
    LPWSTR        lpwsz;
    int           nchar, wcharlength;
    LPDLGTEMPLATE lpdt = (LPDLGTEMPLATE)lpv;

    lpdt->style = style;
    lpdt->dwExtendedStyle = 0;
    lpdt->cdit = ctrlno;
    lpdt->x  = x;  lpdt->y  = y;
    lpdt->cx = cx; lpdt->cy = cy;

    lpw = (LPWORD)(lpdt + 1);

    // No menu
    *lpw = 0;
    lpw++;

    // Predefined dialog box class (by default)
    *lpw = 0;
    lpw++;

    // The title
    lpwsz = (LPWSTR)lpw;
    wcharlength = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, 0);
    nchar = MultiByteToWideChar(CP_ACP, 0, title, -1, lpwsz, wcharlength);
    lpw += nchar;

    // The font used in dialog
    if(style & DS_SETFONT)
    {
       *lpw = 8;
       lpw++;
       lpwsz = (LPWSTR)lpw;
       wcharlength = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, 0);
       nchar = MultiByteToWideChar(CP_ACP, 0, fontname, -1, lpwsz, wcharlength);
       lpw += nchar;
    }

    return lpw;
}
//---------------------------------------------------------------------------

LPWORD CreateDlgControl(LPWORD lpw, WORD ctrlclass, WORD id, LPCTSTR caption,
                      DWORD style, short x, short y, short cx, short cy)
{
    LPDLGITEMTEMPLATE lpdit;
    LPWSTR            lpwsz;
    int               nchar, wcharlength;

    lpw = DWORD_ALIGN(lpw);
    lpdit = (LPDLGITEMTEMPLATE)lpw;
    lpdit->style = style;
    lpdit->dwExtendedStyle = 0;
    lpdit->x  = x ; lpdit->y  = y;
    lpdit->cx = cx; lpdit->cy = cy;
    lpdit->id = id;

    // class
    lpw = (LPWORD)(lpdit + 1);
    *lpw = 0xFFFF;
    lpw++;
    *lpw = ctrlclass;
    lpw++;

    // title
    lpwsz = (LPWSTR)lpw;
    wcharlength = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, 0);
    nchar = MultiByteToWideChar(CP_ACP, 0, caption, -1, lpwsz, wcharlength);
    lpw += nchar;

    // no creation data
    lpw = NON_DWORD_ALIGN(lpw);
    *lpw = 0;
    lpw++;

    return lpw;
}
//---------------------------------------------------------------------------

int InputBox(HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength)
{
    HGLOBAL  hgbl;
    LPWORD   lpw;
    LRESULT  ret;
    DWORD    style;

    hgbl = GlobalAlloc(GMEM_ZEROINIT, 1024);
    if(!hgbl) return 0;
    LPVOID lpv = GlobalLock(hgbl);

    // Prepare the dialog box
    style = DS_SETFONT | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION | WS_VISIBLE;
    lpw = InitDialog(lpv, title, style, 4, "MS Sans Serif", 8, 0, 0, 319, 47);

    // OK-Button
    style = WS_CHILD | WS_VISIBLE | WS_TABSTOP |BS_DEFPUSHBUTTON;
    lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDOK, "OK", style, 264, 7, 48, 15);

    // Cancel-Button
    style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
    lpw = CreateDlgControl(lpw, BUTTON_CLASS, IDCANCEL, "Abbrechen", style, 264, 26, 48, 15);

    // Text to prompt
    style = WS_CHILD | WS_VISIBLE | SS_LEFT;
    lpw = CreateDlgControl(lpw, STATIC_CLASS, ID_INFOTEXT, prompt, style, 10, 9, 129, 16);

    // Edit-Control
    style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP;
    lpw = CreateDlgControl(lpw, EDIT_CLASS, ID_INPUT, "", style, 10, 26, 249, 13);

    GlobalUnlock(hgbl);
    int data[2] = {(int)buffer, buflength};
    ret = DialogBoxIndirectParam(NULL, (LPDLGTEMPLATE)hgbl, hwnd,
                                 (DLGPROC)InputBoxDlgProc, (int)data);
    GlobalFree(hgbl);
    return (ret > 0) ? ret : 0;
}
//---------------------------------------------------------------------------

BOOL CALLBACK InputBoxDlgProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
   static char* buf;
   static int   buflength;
   static HFONT hFont;

   switch(uiMsg)
   {
      case WM_INITDIALOG:
      {
         int* data = (int*)lParam;
         buf = (char*)data[0];
         buflength = data[1];
         HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
         SetFocus(hEdit);
         break;
      }

      case WM_SETFONT:
         hFont = (HFONT)wParam;
         break;

      case WM_CLOSE:
         EndDialog(hwnd, IDCANCEL);
         DeleteObject(hFont);
         break;

      case WM_COMMAND:
      {
         switch(LOWORD(wParam))
         {
            case IDOK:
            {
               HWND hEdit = GetDlgItem(hwnd, ID_INPUT);
               GetWindowText(hEdit, buf, buflength);
               EndDialog(hwnd, IDOK);
               DeleteObject(hFont);
               break;
            }

            case IDCANCEL:
            {
               EndDialog(hwnd, IDCANCEL);
               break;
            }
         }
      }
   }
   return FALSE;
}
//---------------------------------------------------------------------------

VOID ShowMessage(HWND hwnd, LPCTSTR lpszMsg, LPCTSTR lpszTitle, WORD wIcon)
{
   UINT uType = 0;
   if(wIcon == SM_WARNING)
      uType = MB_ICONWARNING;
   else if(wIcon == SM_INFO)
      uType = MB_ICONINFORMATION;
   else if(wIcon == SM_ERROR)
      uType = MB_ICONERROR;

   MessageBox(hwnd, lpszMsg, lpszTitle, uType);
}
//---------------------------------------------------------------------------

Dann kannst du eine solche InputBox wie folgt aufrufen:
C/C++ Code:
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
char buffer[256];

int ret = InputBox(hwnd, "Eingabe in diesem Feld:", "Titel", buffer, 256);
if(ret == IDOK)
   MessageBox(hwnd, buffer, "Die Eingabe war:", MB_OK | MB_ICONINFORMATION);
else if(ret == IDCANCEL)
   MessageBox(hwnd, "Es wurde \"Abbrechen\" gewählt", "INFO", MB_OK | MB_ICONINFORMATION);
else if(ret == 0)
   MessageBox(hwnd, "Ein Fehler ist aufgetreten", "INFO", MB_OK | MB_ICONERROR);
C/C++ Code:
1
2
3
4
5
6
7
8
9
char buffer[256];

int ret = InputBox(hwnd, "Eingabe in diesem Feld:", "Titel", buffer, 256);
if(ret == IDOK)
MessageBox(hwnd, buffer, "Die Eingabe war:", MB_OK | MB_ICONINFORMATION);
else if(ret == IDCANCEL)
MessageBox(hwnd, "Es wurde \"Abbrechen\" gewählt", "INFO", MB_OK | MB_ICONINFORMATION);
else if(ret == 0)
MessageBox(hwnd, "Ein Fehler ist aufgetreten", "INFO", MB_OK | MB_ICONERROR);
C/C++ Code:
1
2
3
4
5
6
7
8
9
char buffer[256];

int ret = InputBox(hwnd, "Eingabe in diesem Feld:", "Titel", buffer, 256);
if(ret == IDOK)
   MessageBox(hwnd, buffer, "Die Eingabe war:", MB_OK | MB_ICONINFORMATION);
else if(ret == IDCANCEL)
   MessageBox(hwnd, "Es wurde \"Abbrechen\" gewählt", "INFO", MB_OK | MB_ICONINFORMATION);
else if(ret == 0)
   MessageBox(hwnd, "Ein Fehler ist aufgetreten", "INFO", MB_OK | MB_ICONERROR);

Ich habe jetzt rund 48 Stunden dafür gebraucht. Dabei war Knobeln an der Tagesordnung, denn die MS-Dokumentation zu DialogBoxIndirect() ist sehr schlecht und fehlerhaft in mehreren Punkten. Im Netz ist auch nicht das Wahre zu finden. Aber jetzt steht das ganze hoffentlich (ohne Fehler), und man kann nicht nur InputBoxes damit erstellen, sondern Dialoge jeglicher Art. Dazu schaue man sich die Funktion InputBox() an. Diese nutzt wiederum die Funktionen InitDialog() und CreateDlgControl(), mit denen man seinen Dialog erstellen kann wie auch in einem Resourcen-Script. Viel Spaß damit.

[ Dieser Beitrag wurde am 22.02.2003 um 21:30 Uhr von WebFritzi editiert. ]

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
dange!
Unregistrierter




Beitrag dange! Unregistrierter 10:13:00 15.11.2002   Titel:              Zitieren

öhm ... WebFritzi, bin hier mal als Trittbrettfahrer. Son Ding hab ich schon öfter gebraucht, bin blos bislang nicht dazu gekommen das selber zu basteln. Hab deinen Code zwar noch nicht probiert, aber sieht gut aus. Denke, ich werd da einen "Standard-Include" bei mir draus machen.
Vielleicht kann ich mich ja mal mit irgendwas revangieren.
frage!
Unregistrierter




Beitrag frage! Unregistrierter 13:52:00 15.11.2002   Titel:              Zitieren

@WebFritz: Warum hast du das mit diesem dummen DLGITEMTEMPLATE gemacht und nicht mit CreateWindow? :confused:
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 17:33:00 15.11.2002   Titel:              Zitieren

@frage!
Weil ich das eben mit nem Dialog machen wollte. Hast du noch nie das Gefühl gehabt, eine Herausforderung annehmen zu müssen? ;)

@dange!
Bidde!

[ Dieser Beitrag wurde am 11.12.2002 um 00:23 Uhr von WebFritzi editiert. ]

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 06:51:00 16.11.2002   Titel:              Zitieren

Für den FAQ-Leser: Alles, was jetzt noch kommt, ist unwichtig!

[ Dieser Beitrag wurde am 11.12.2002 um 00:24 Uhr von WebFritzi editiert. ]

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
tipp!
Unregistrierter




Beitrag tipp! Unregistrierter 09:22:00 16.11.2002   Titel:              Zitieren

mach doch SendMessage mit WM_SETFONT
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 18:20:00 16.11.2002   Titel:              Zitieren

hi,

ich hätte nicht gedacht, dass es so schwer ist eine inputbox zu machen,
das ist ja wahnsinn, bin ich der erste der sowas braucht(e)??

ich schaffs nicht, die datei einzubinden, der meckert immer irgendwo rum,
ich habe eine inputbox.h erstellt, in der steht das:
C/C++ Code:
int InputBox(HINSTANCE hInst, HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength);
C/C++ Code:
int InputBox(HINSTANCE hInst, HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength);
C/C++ Code:
int InputBox(HINSTANCE hInst, HWND hwnd, LPCTSTR prompt, LPCTSTR title, LPTSTR buffer, INT buflength);

und die datei die hier gepostet ist habe ich inputbox.cpp genannt.
dann habe ich das hier versucht:
C/C++ Code:
int i = InputBox(hInstance, hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }
C/C++ Code:
int i = InputBox(hInstance, hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }
C/C++ Code:
int i = InputBox(hInstance, hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }

bei den ersten beiden parametern habe ich mein problem,
NULL kann ich nicht bei beiden nehmen, das weiß ich jetzt auch schon,
aber wenn ich
hInstanc2 als HINSTANCE
und
hWn2 als HWND
deklariere, dann kommt diese meldung:
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HINSTANCE__ *,struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHINSTANCE__@@PAUHWND__@@PBD2PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HINSTANCE__ *,struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHINSTANCE__@@PAUHWND__@@PBD2PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HINSTANCE__ *,struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHINSTANCE__@@PAUHWND__@@PBD2PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.


ist bestimmt wieder nur n minifehler von mir, aber ich hab das mit hwnd und hinstance... noch nicht so raus! :(

Danke für die Mühe,

Cu, Ronny
Christoph
Moderator

Benutzerprofil
Anmeldungsdatum: 30.04.2001
Beiträge: 5712
Beitrag Christoph Moderator 22:34:00 16.11.2002   Titel:              Zitieren

Du solltest den Code von WebFritzi auch noch als .cpp datei speichern und dazulinken. :)

@WebFritzi:
Ist der Code so in Ordnung? Ich schiebs dann nämlich mal in die FAQ, da sowas ja öfter gebraucht wird.

_________________
Wenn Word für Längeres geeignet wäre, würde es nicht Word, sondern Sentence, Page oder Article heißen.
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 00:15:00 17.11.2002   Titel:              Zitieren

Zitat:
Original erstellt von Netspider:

und die datei die hier gepostet ist habe ich inputbox.cpp genannt.


habe ich ja, zumindest gespeichert, ich dachte es reicht wenn ich die InputBox.h include, aber ok!
muss ich die ersten 2 parameter eigentlich ändern oder geht das so wie es im beispiel von webfritzi geschrieben ist?
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 03:55:00 17.11.2002   Titel:              Zitieren

@cd9000
JETZT ist der Code hoffentlich in Ordnung, und ich wäre dankbar dafür, wenn du das in die FAQ stellen würdest. Dann kann ich mir wenigstens immer wieder die Früchte meiner Anstrengung anschauen. ;)

@Netspider
Den ersten Parameter habe ich in der neuen Fassung herausgenommen. Der war eh überflüssig, weil man in DialogBoxIndirectParam() auch NULL im ersten Parameter stehen haben kann, wenn man die DLGTEMPLATE nicht gerade aus einer Resource geladen hat. Du solltest jetzt keine Probleme mehr damit haben. Tipp einfach das Beispiel in meinem langen Beitrag ab.

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
Kind
Unregistrierter




Beitrag Kind Unregistrierter 04:41:00 17.11.2002   Titel:              Zitieren

WebFritzi: Fein, danke! :)
Netspider
Mitglied

Benutzerprofil
Anmeldungsdatum: 05.06.2002
Beiträge: 81
Beitrag Netspider Mitglied 12:18:00 17.11.2002   Titel:              Zitieren

irgendwie bin ich nicht in der lage, das zu starten: *grübel*
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHWND__@@PBD1PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHWND__@@PBD1PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Code:
error LNK2001: unresolved external symbol "int __cdecl InputBox(struct HWND__ *,char const *,char const *,char *,int)" (?InputBox@@YAHPAUHWND__@@PBD1PADH@Z)
Debug/Nimm3D.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ich habe #include "InputBox.h" gemacht, die neue version von deiner cpp-datei in die InputBox.cpp geschrieben und die InputBox.h mit deinem text geschrieben.
dann habe ich die funktion so aufgerufen:
C/C++ Code:
int i = InputBox(hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }
C/C++ Code:
int i = InputBox(hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }
C/C++ Code:
int i = InputBox(hWnd, "Eingabe in diesem Feld:", "Titel", sDummy, 256);
if(i==IDOK)
{ MessageBox(NULL, sDummy, "Text", MB_OK); }

was ist denn daran falsch, muss ich ein frisches "hWnd" benutzen, das hier ist das von meinem fenster, das erstellt wurde.
- ich kenn mich mit win-cpp eben nicht so aus -
Danke für eure hilfe, wenn mir noch jemand dabei helfen kann, den error auszuradieren, dann bin ich richtig glücklich!

Cu, Ronny
WebFritzi
Mitglied

Benutzerprofil
Anmeldungsdatum: 23.09.2001
Beiträge: 9879
Beitrag WebFritzi Mitglied 15:39:00 17.11.2002   Titel:              Zitieren

Du musst natürlich die cpp-Datei zu deinem Projekt hinzufügen (Im VC++: Projekt->Dem Projekt hinzufügen...).

_________________
Riskiere doch mal einen Blick auf www.WebFritzi.de.vu
FROM: doofie (192.255.2.88); TO: WebFritzi (212.128.130.6)
hi, i'm a signature virus. copy me into your signature to help me spread.
C/C++ Forum :: FAQ - WinAPI ::  Inputbox (oder allg. Dialoge ohne Resourcen)   Auf Beitrag antworten

Zeige alle Beiträge auf einer Seite




Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Sie können keine Beiträge in dieses Forum schreiben.
Sie können auf Beiträge in diesem Forum nicht antworten.
Sie können Ihre Beiträge in diesem Forum nicht bearbeiten.
Sie können Ihre Beiträge in diesem Forum nicht löschen.
Sie können an Umfragen in diesem Forum nicht mitmachen.

Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme

c++.de ist Teilnehmer des Partnerprogramms von Amazon Europe S.à.r.l. und Partner des Werbeprogramms, das zur Bereitstellung eines Mediums für Websites konzipiert wurde, mittels dessen durch die Platzierung von Werbeanzeigen und Links zu amazon.de Werbekostenerstattung verdient werden kann.

Die Vervielfältigung der auf den Seiten www.c-plusplus.de, www.c-plusplus.info, www.c-sar.de, www.c-plusplus.net und www.baeckmann.de enthaltenen Informationen ohne eine schriftliche Genehmigung des Seitenbetreibers ist untersagt (vgl. §4 Urheberrechtsgesetz). Die Nutzung und Änderung der vorgestellten Strukturen und Verfahren in privaten und kommerziellen Softwareanwendungen ist ausdrücklich erlaubt, soweit keine Rechte Dritter verletzt werden. Der Seitenbetreiber übernimmt keine Gewähr für die Funktion einzelner Beiträge oder Programmfragmente, insbesondere übernimmt er keine Haftung für eventuelle aus dem Gebrauch entstehenden Folgeschäden.