Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

11

15.04.2008, 19:41

Naja ...

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
typedef std::basic_string<TCHAR> tstring;

const tstring get_window_text(::HWND const& hWnd)
{
    const std::size_t size(::GetWindowTextLength(hWnd) + 1);
    TCHAR* ptr_string(new TCHAR[size]);
    ::GetWindowText(hWnd, ptr_string, size);
    const tstring temp(ptr_string);
    delete [] ptr_string;
    return temp;
}
... so lesen wir mal den Fenstertext aus ;)

C-/C++-Quelltext

1
2
3
std::basic_ostringstream<TCHAR> ss(get_window_text(hWndEdit));
int i(0);
ss >> i;
... schon steht in i was du willst ;)
Devil Entertainment :: Your education is our inspiration
Der Spieleprogrammierer :: Community Magazin
Merlin - A Legend awakes :: You are a dedicated C++ (DirectX) programmer and you have ability to work in a team? Contact us!
Siedler II.5 RttR :: The old settlers-style is comming back!

Also known as (D)Evil

12

19.04.2008, 15:12

Muss man dazu irgendwelche bestimmten Dateien einbinden?

13

19.04.2008, 21:25

Jap.
<sstream>
<string>
<windows.h>
<tchar.h>
Devil Entertainment :: Your education is our inspiration
Der Spieleprogrammierer :: Community Magazin
Merlin - A Legend awakes :: You are a dedicated C++ (DirectX) programmer and you have ability to work in a team? Contact us!
Siedler II.5 RttR :: The old settlers-style is comming back!

Also known as (D)Evil

14

22.04.2008, 17:06

Hmm, irgendwie funktioniert das nicht so wie es soll. Hier mal der Fehler:

Quellcode

1
2
3
4
5
6
7
8
9
10
1>------ Erstellen gestartet: Projekt: Tobias, Konfiguration: Debug Win32 ------
1>Kompilieren...
1>Callback.cpp
1>c:\mein c++\visual studio 2008\projects\projektmappe3\tobias\callback.cpp(12) : error C2660: 'GetWindowTextLengthA': Funktion akzeptiert keine 0 Argumente
1>c:\mein c++\visual studio 2008\projects\projektmappe3\tobias\callback.cpp(12) : fatal error C1903: Weiterverarbeitung nach vorherigem Fehler nicht möglich; Kompilierung wird abgebrochen.
1>Steuerelemente.cpp
1>Code wird generiert...
1>Das Buildprotokoll wurde unter "file://c:\Mein C++\Visual Studio 2008\Projects\Projektmappe3\Tobias\Debug\BuildLog.htm" gespeichert.
1>Tobias - 2 Fehler, 0 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========


Es liegt ja wohl daran, dass GetWindowTextLength nichts übergeben wurde. Wenn ich dies aber tun will habe ich auf einmal 36 Fehler...

15

22.04.2008, 18:00

Hab es oben korrigiert ...
Devil Entertainment :: Your education is our inspiration
Der Spieleprogrammierer :: Community Magazin
Merlin - A Legend awakes :: You are a dedicated C++ (DirectX) programmer and you have ability to work in a team? Contact us!
Siedler II.5 RttR :: The old settlers-style is comming back!

Also known as (D)Evil

16

22.04.2008, 20:10

Wie gesagt kommen jetzt die 36 Fehler. Wo müssen die Sachen denn stehen?

Muss das erste auch in der Callback-Funktion selbst stehen? Wohl eher nicht denke ich.

Ich kann auch die Fehler hier reinstellen, aber das wird dann ziemlich lang. :D

17

22.04.2008, 23:04

stell se rein oder schick mir dein Projekt ... dann räum ich es dir die tage auf ...
Devil Entertainment :: Your education is our inspiration
Der Spieleprogrammierer :: Community Magazin
Merlin - A Legend awakes :: You are a dedicated C++ (DirectX) programmer and you have ability to work in a team? Contact us!
Siedler II.5 RttR :: The old settlers-style is comming back!

Also known as (D)Evil

18

23.04.2008, 16:31

Habs als rar-Datei gepackt und hier hochgeladen: Klick

19

23.04.2008, 22:29

C oder C++? Also ein Code ist zu >90% C :D

Fehler
Es muss std::basic_istringstream und nicht std::basic_ostringstream heißen.

Willst du Tipps zur Verbesserung?
Dann sag nochmal bescheid. Da lässt sich einiges machen!
Devil Entertainment :: Your education is our inspiration
Der Spieleprogrammierer :: Community Magazin
Merlin - A Legend awakes :: You are a dedicated C++ (DirectX) programmer and you have ability to work in a team? Contact us!
Siedler II.5 RttR :: The old settlers-style is comming back!

Also known as (D)Evil

20

23.04.2008, 23:46

Erstmal will ich alle Abläufe verstehen, danach bin ich gegenüber Verbesserungen nicht abgeneigt. ;)

Werbeanzeige