Waitrud Weber’s blog

things and reminders for memories

3d: WindowsAPI: Windows-make: How do we face memories problem: we can cast ASCII to LPSTR:

We can cast ASCII to LPSTR:

 

 

---

f:id:Waitrud_Weber:20200530191925p:plain


---

 

---

 

.\wButton.cpp  Sat May 30 19:22:12 2020

 60 :
 61 :int wButton::drawButton(  HDC hdc ) {
 62 :
 63 :	RECT rect;
 64 :	//SetTextColor( hdc, RGB(0 ,0, 255));
 65 :	//Rectangle( hdc, rect->left, rect->top, rect->right, rect->bottom );
 66 :	//DrawText( hdc, TEXT( button_name ), -1, rect, DT_NOCLIP);
 67 :
 68 :	// Calculation of right and bottom
 69 :	int right = this->x + this->width;
 70 :	int bottom = this->y + this->height;
 71 :
 72 :    SetRect(&rect, this->x, this->y, right, bottom);
 73 :
 74 :	if ( this->mode == 0 )
 75 :		SetTextColor( hdc, RGB( 0 ,0, 255 ) );
 76 :	else
 77 :		SetTextColor( hdc, RGB( 255 ,0, 0 ) );
 78 :
 79 :	Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom );
 80 ://	DrawText( hdc, (LPWSTR)( this->button_name ), -1, &rect, DT_NOCLIP);
 81 ://	qualified: DrawText( hdc, TEXT( "Const Character" ), -1, &rect, DT_NOCLIP);
 82 ://	DrawText( hdc, this->button_name, -1, &rect, DT_NOCLIP);
 83 :	DrawText( hdc, text(this->button_name), -1, &rect, DT_NOCLIP ) ; // x
 84 :
 85 :	//  LPWSTR -> wchar_t: 
 86 :	//	DrawText doesn't matter.
 87 :
 88 :	return 1;
 89 :}
 90 :
 91 :LPSTR result_001[255];
 92 :
 93 :LPWSTR text(char* msg) {
 94 :	LPWSTR result = (LPWSTR)"default";
 95 :	///LPSTR result_001[255];
 96 :
 97 :	// CHAR -> char
 98 :	result_001[0] = (LPSTR) 'm';
 99 :	result_001[1] = (LPSTR) '\0';
100 :
101 :	return (LPWSTR)result_001;
102 :}
103 :