Hello list!, i have two questions that i hope that someone of you could answer.
The first one: - Should RegOpenKeyExW() do a SetLastError() or it just return an error code? I ask this because in the timedate control panel applet, GetSyncSetting() reads a key from the registry using that function and if it fails it calls the function GetError() that calls FormatMessage() using GetLastError() as an argument. For some reason in my computer this call fails and i receive an window that says "ERROR_INVALID_WINDOW_HANDLE" that obviously is not the right error code.
This bug could be reproduced by double clicking in the Hour located in the right corner of the start menu bar. Next you click the Internet Time tab and you should receive the error.
To fix this i can think of two possibilities: - Modify RegOpenKeyExW() to do a SetLastError() if this fails to set a right code for GetLastError(), or - Modify the GetError() function in the timedate control panel applet I don't know which is the right way to fix this.
Finally in my opinion, if an error occurs in this situation i think that no message should appear because i think that is not too bad if this key isn't present.
And the second question follows... - I have written a program that displays a Status bar using the DrawStatusText() function. In Windows it is working pretty well but in ReactOS it doesnt. DrawStatusText() in ReactOS doesnt draw a background when calling this function thus my status window draws over itself each time i receive a WM_PAINT message. So its clear that in windows DrawStatusText() draws a background before painting the text, but in ReactOS it doesnt. Currently i have hacked the DrawStatusText() function to draw a background like this:
void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style) { RECT r = *lprc; UINT border = BDR_SUNKENOUTER; HBRUSH hBkBrush, hOldBrush;
if (style & SBT_POPOUT) border = BDR_RAISEDOUTER; else if (style & SBT_NOBORDERS) border = 0;
DrawEdge (hdc, lprc, border, BF_RECT|BF_ADJUST);
/* now draw text */ if (text) { int oldbkmode = SetBkMode (hdc, TRANSPARENT); UINT align = DT_LEFT; if (*text == L'\t') { text++; align = DT_CENTER; if (*text == L'\t') { text++; align = DT_RIGHT; } } r.left += 3; if (style & SBT_RTLREADING) FIXME("Unsupported RTL style!\n"); // yep this fixed the problem, but i don't know what the // right color it is hBkBrush = GetSysColorBrush(GetSysColor(COLOR_BTNFACE)); hOldBrush = SelectObject(hdc, hBkBrush); FillRect(hdc, lprc, hBkBrush); DrawTextW (hdc, text, -1, lprc, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
SelectObject(hdc, hOldBrush);
SetBkMode(hdc, oldbkmode); } }
Attached i send the code that shows this "bug" and a precompiled binary. Also i have tested this program under WINE with the same results (0.9.x i think).
Thats all, Best regards, Felipe Villarroel
Felipe Villarroel wrote:
Hello list!, i have two questions that i hope that someone of you could answer.
The first one:
- Should RegOpenKeyExW() do a SetLastError() or it just return an
error code? I ask this because in the timedate control panel applet, GetSyncSetting() reads a key from the registry using that function and if it fails it calls the function GetError() that calls FormatMessage() using GetLastError() as an argument. For some reason in my computer this call fails and i receive an window that says "ERROR_INVALID_WINDOW_HANDLE" that obviously is not the right error code.
Yeah, that's wrong. FormatMessage should use the return value from RegOpenKeyEx.
- Modify the GetError() function in the timedate control panel
applet
I have many fixes and more code for this in my working copy. I was originally working in NTP functionality but left it. I hadn't realised part of my code was in trunk. It must of got caught up when we rearranged the tree layout.
I'll get back onto NTP soon and finish it off.
Ged.