As requested, I'm trying to make a new uninstaller using a dialog instead of a window.
It's my first windows program and I have something working but there are still some issues.
If someone could help with some of the following problems, I'd be very thanfull.
1) Strange problem with UpdateWindow uninstaller.c, line 264 I implemented a search/filter field and I want to repaint the window after each input in the EDITTEXT control. However, when I call UpdateWindow on this line, the value returned is 1 so that a WM_PAINT message should be sent right ? But strangly no message is sent and I have to make something else (like moving the dialog) to force the window to repaint and filter the entries. The funny thing is that UpdateWindow on line 279 works just fine. I guess it's a bug in my code and not in Wine so I'd be glad if you could help me.
2) Improve filter code Currently I filter the entries that match exactly the filter string. I would like to at least make a case insensitive strstr on the string. What's the best way to do it (See uninstaller.c, line 235)
3) Stringtables a)Is there a way to load localized strings without having to guess beforehand the size of the string in each language ? b)Is there a way to not call LoadString for each string ? c)Where is the best place to load every string of a stringtable ? in main(), just before calling DialogBox() ?
4) Please tell me if you see things that are bad in the attached code, so that I'll fix it before submitting a patch.
Thanks you for your help
Jonathan Ernst wrote:
- Please tell me if you see things that are bad in the attached code,
so that I'll fix it before submitting a patch.
I think you probably want to pass a valid HINSTANCE to DialogBox, to do this you should start your program with WinMain() instead of main().
Ivan.
"Ivan Leo Puoti" ivanleo@gmail.com wrote:
Jonathan Ernst wrote:
- Please tell me if you see things that are bad in the attached code,
so that I'll fix it before submitting a patch.
I think you probably want to pass a valid HINSTANCE to DialogBox, to do this you should start your program with WinMain() instead of main().
main() works just fine. GetModuleHandle(0) returns current HINSTANCE.
Jonathan Ernst wrote:
As requested, I'm trying to make a new uninstaller using a dialog instead of a window.
It's my first windows program and I have something working but there are still some issues.
If someone could help with some of the following problems, I'd be very thanfull.
Cool. Some comments:
The dialog box procedure should not handle WM_PAINT or WM_CLOSE, so just delete those cases from the switch statement.
Don't send WM_SETFONT messages to the controls in the dialog. Let the dialog template define what the dialog looks like.
Your WM_INITDIALOG handler should fill the listbox, not WM_PAINT.
You can remove the "No items selected" message if uninstall is clicked without a listbox element select. That's just going to annoy people, and it's not internationalized.
Mike
Le samedi 26 février 2005 à 09:49 +0900, Mike McCormack a écrit : [...]
Cool. Some comments:
The dialog box procedure should not handle WM_PAINT or WM_CLOSE, so just delete those cases from the switch statement.
Ok I did it, but the listbox should be updated when the user ask to uninstall someting OR the user changes the filter string ? How can I do that using only WM_INITDIALOG ?
Don't send WM_SETFONT messages to the controls in the dialog. Let the dialog template define what the dialog looks like.
I removed it.
Your WM_INITDIALOG handler should fill the listbox, not WM_PAINT.
See my first question.
You can remove the "No items selected" message if uninstall is clicked without a listbox element select. That's just going to annoy people, and it's not internationalized.
I removed it. Internationalizaton will come after everything is alright.
Thanks.
P.S. Ivan Leo Puti I don't know if it'll be better to use WinMain. Using WinMain will make me to parse the command line manually isn't it ?
Jonathan Ernst wrote:
Ok I did it, but the listbox should be updated when the user ask to uninstall someting OR the user changes the filter string ? How can I do that using only WM_INITDIALOG ?
You can get notifications from the controls that things change. For example, the edit control will send a WM_COMMAND( EN_CHANGE ) when the contents change.
WM_INITDIALOG is just for setting things up.
So create a function like fill_combo_box(), and call it whenever you need to update the combo box... when handling WM_COMMAND( EN_CHANGE ), WM_INITDIALOG, etc.
Mike
"Jonathan Ernst" Jonathan@ErnstFamily.ch wrote:
- Strange problem with UpdateWindow
uninstaller.c, line 264 I implemented a search/filter field and I want to repaint the window after each input in the EDITTEXT control. However, when I call UpdateWindow on this line, the value returned is 1 so that a WM_PAINT message should be sent right ?
No. UpdateWindow only sends WM_PAINT if there are invalidated areas to repaint. You need to use InvalidateRect first.
Are you sure you want to repaint the whole window on each EN_CHANGE and not some small area of a dialog?
But strangly no message is sent and I have to make something else (like moving the dialog) to force the window to repaint and filter the entries. The funny thing is that UpdateWindow on line 279 works just fine. I guess it's a bug in my code and not in Wine so I'd be glad if you could help me.
- Improve filter code
Currently I filter the entries that match exactly the filter string. I would like to at least make a case insensitive strstr on the string. What's the best way to do it (See uninstaller.c, line 235)
Just send LB_FINDSTRING or LB_FINDSTRINGEXACT to listbox, it will do the job for you.
- Stringtables
a)Is there a way to load localized strings without having to guess beforehand the size of the string in each language ? b)Is there a way to not call LoadString for each string ? c)Where is the best place to load every string of a stringtable ? in main(), just before calling DialogBox() ?
It's better to void using string tables, since now you have converted code to use dialog box instead.
- Please tell me if you see things that are bad in the attached code,
so that I'll fix it before submitting a patch.
+BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
BOOL -> INT_PTR
WM_PAINT is not needed for dialog boxes, user32 does the job.
+int main(int argc, char *argv[]) +{
- MSG msg;
- WNDCLASS wc;
- HWND hWnd;
- LPSTR token = NULL;
- int i = 1;
- HINSTANCE hInst = NULL;
HINSTANCE hInst = GetModuleHandle(0);
Le samedi 26 février 2005 à 12:09 +0800, Dmitry Timoshkov a écrit : [...]
- Stringtables
a)Is there a way to load localized strings without having to guess beforehand the size of the string in each language ? b)Is there a way to not call LoadString for each string ? c)Where is the best place to load every string of a stringtable ? in main(), just before calling DialogBox() ?
It's better to void using string tables, since now you have converted code to use dialog box instead.
How can I do it for messageboxes ? Is there a way to define them in the resource files or do I have to make a dialog instead of messageboxes ?
Thanks everyone for your comments, I'll send an updated version soon.
"Jonathan Ernst" Jonathan@ErnstFamily.ch wrote:
It's better to avoid using string tables, since now you have converted code to use dialog box instead.
How can I do it for messageboxes ? Is there a way to define them in the resource files or do I have to make a dialog instead of messageboxes ?
Yes, one of the possibilities to use dialog boxes instead of message boxes. But if it's inconvenient for you, then using string tables and LoadString is the only option.
Here is a new version.
I'm thinking to send it as is to wine-patches if nobody complains before tonight (tomorrow I'll be leaving for one week).
Thanks everyone for your help.
Changelog: - new uninstaller - "find as you type" search - use dialog instead of window - internationalization - if the uninstaller cannot be found the user can choose to remove the entry from the registry
"Jonathan Ernst" Jonathan@ErnstFamily.ch wrote:
I'm thinking to send it as is to wine-patches if nobody complains before tonight (tomorrow I'll be leaving for one week).
First of all thanks for your efforts. Since this is your first Win32 app I personally understand all the difficulties you faced with. Please do not be offenced by critical comments below, they are supposed to help you better understand your mistakes and should serve as a guide for further improvements.
+int list_need_update = 1; +int oldsel = -1; +int FetchUninstallInformation(void); +char *sFilter;
I'd suggest to not mix variables and function declarations. Another suggestion is to use static modifier for everything since nothing is supposed to be externally visible.
If you could use unicode for everything internally that would be another great bonus for us poor non latin1 using people. You are rewriting the app almost entirely anyway. Just replace main by wmain and Wine startup code will pass unicode strings to it, but make sure to use CP_UNIXCP to convert strings from unicode to unix locale before printing them to the unix console.
Please use Win32 APIs for string comparisons since Wine and unix locales are almost always not the same. Using unicode will drop this requirement.
Avoid using c++ comments, they are deprecated for Wine code.
Use consistent formatting through the code.
if(sFilter != NULL && stristr(wine_dbgstr_w(entries[numentries-1].descr),sFilter)==NULL)
numentries--;
wine_dbgstr_w is not supposed for the above use. Using unicode will help to avoid such ugly constructs.
RemoveSpecificProgram( argv[i++] );
argv[] list is passed in the unix locale while the code expects to see it in the win32 locale. Using unicode will fix it as well.
+char *stristr(const char *String, const char *Pattern) +{
- char *pptr, *sptr, *start;
- uint slen, plen;
- for (start = (char *)String,
pptr = (char *)Pattern,
Why not simply use "const char *" for pptr, sptr, start instead of silencing compiler warnings and hiding potential bugs?
- {
/* find start of pattern in string */
while (toupper(*start) != toupper(*Pattern))
Again an issue with unix/win32 locale mixup.
Hey,
On Mon, 28 Feb 2005 17:52:25 -0800, Scott Ritchie scott@open-vote.org wrote:
These are errors outside the control of PHP. This is caused by the mysql daemon not responding correctly to a correct query.
Paul
I'll look into this. I have been unable to reproduce it thus far. If it continues, please file a bugzilla bug on it.
On Tue, 2005-03-01 at 12:00 +0100, Paul van Schayck wrote:
Hey,
On Mon, 28 Feb 2005 17:52:25 -0800, Scott Ritchie scott@open-vote.org wrote:
These are errors outside the control of PHP. This is caused by the mysql daemon not responding correctly to a correct query.
Paul