c++ class in class

  • Thread starter Thread starter josh.bauer2020
  • Start date Start date
J

josh.bauer2020

Guest
class buttonClass {
HWND hwnd;
class TextClass {
const int TextClassMaxLen = 100;
public:
operator string () {
string windowText(TextClassMaxLen);
GetWindowTextA(hwnd, (char*)windowText, TextClassMaxLen);
return windowText;
}
} ;
public:
TextClass Text;
buttonClass(HWND parent) {
HINSTANCE moduleHandle = GetModuleHandle(0);
hwnd = CreateWindowA("BUTTON", "temp", WS_CHILD | WS_VISIBLE, 1, 1, 150, 30, parent, NULL, moduleHandle, NULL);
}

};

1) It throws me error upon compilation. It says that hwnd in GetWindowTextA cannot be reached.

How to get hwnd?

2) Is there not any: friend string& operator=(string& paramString, TextClass& paramTextClass);

I do

buttonClass button(parent);


string myString=button.Text;

I assume there is not operator= so I do it by conversion to string.

What is best way to do it?

Continue reading...
 
Back
Top