|
I highly recommend that you redesign the program such that the worker thread sends a message to main thread for control update.
Kuphryn
|
|
|
|
|
SendMessage() is very dangerous from a worker thread, and can lead to a deadlock. PostMessage() is the safe way to go.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Hi ppl
I created a child windows and I passed the child window handle to a function. And inside that function I used TextOut to print out simply "hallo"
So I simply use
TextOut(hdc, 10, 10, "hallo", 5);
One line is fine, but if I called TextOut like 10 times and incrementing like
TextOut(hdc, 10, 30, "hallo2", 5);<br />
TextOut(hdc, 10, 50, "hallo3", 5);<br />
TextOut(hdc, 10, 70, "hallo4", 5);<br />
.<br />
.<br />
.
Then some of the "hallo"s will be out of the range of the child window and cannot be displayed. So anyone can help me how to make it scrollable?
And another thing is when I resize the child window, like maximizing or minimizing it. The texts will be all gone. So I think that has sth to do with WM_PAINT, right? But how should I make it?
Thanz!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
Oh actually I'm trying to make the application window like a console window, displaying text
So when the text goes on and on, the most recent text will be inside the window's view while the previous ones are scrolled upwards...um...you know what I mean.. hehe
And yes I'm using C to call the windows API using DEV C++ as compiler running on windows XP
So do any of you guyz have any idea on how to make it? Just displaying text on the application window? Thanz!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
This is elementary windows programming. Look up scrollbars in the help. With each line you'll need to set the range of the scroll bar and the position. At some point you'll likely need, and want, to chuck old lines.
There is no magic, just brute force programming.
|
|
|
|
|
Oh but the thing is if I know what I am gonna print, I can use TextOut in the case WM_PAINT. But actually my program is written based on UNIX programming, so I have all those printf and getchar.
And now I simply changed the printf into TextOut. So the TextOut are essentially in the functions that I will call, but not really in the WM_PAINT. That's the tough part for me.
So should I use a buffer or file, and replace all those printf with sth that write into the buffer or file. And then use TextOut to write what is inside the buffer?
Thanz really!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
Use wsprintf and store each line in a CStringArray. You'll need to do this anyway if you want to refresh the screen.
Maintain an index into this array of the top line.
As you write the lines, if the next line will overlap the bottom of the view, you'll need to shift the existing lines up and write the new line where the previous bottom line was. (I suggest precalculating this using GetTextExtent() at start and whenever the view size is changed.)
To scroll the contents up, use CDC::ScrollDC().
(If you're going to have lots of text, you may want to virtualize the above list, though you would still want to buffer up what's actually being displayed.)
|
|
|
|
|
hi,
i want to know how to build a application with multi-language. actually, 3 questions i want to ask...
1) how to change language at run-time (eg. change language btn. trad. chinese, simplified chinese and english by clicking in menu)
2) how to display 2 type of language in same dialog box (eg. button text is traditional chinese, and i can input japanese or simplfied chinese in text box, is it possible?)
3) how can i build a unicode application? where able to find the unicode library? is it the best solution for my situation?
thanks,
jim
|
|
|
|
|
One method is descibed in my article http://www.codeproject.com/cpp/mult_lang_support.asp[^]
If you use the resouce language DLL approach 2) can be achieved by getting the language text from the specific language DLL and explicity setting the text for the relevant control.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
that's impressive! but, i want to know whether it work on button or controls on a dialog?
i tried and found that windows handle menu text and dialog text in different way. when i set the default font as trad. chinese and included simplified chinese in my regional settings. i can see correct text in menu but wrong text in a dialog. when i set simplified chinese as default font, i can see everythings correct.
do u have any more complete information on this aspect?
thanks,
jim
|
|
|
|
|
I can't speak Chinese, ony Polish! Using a resource only DLL means you have to define the menus, dialogs etc. in each language for each resource only DLL. Then when a new resource only DLL is loaded, the Menus Dialogs etc. from the new DLL will be used, rather that the default resources.
But if you just want to use a French text string on and English Dialog box you could do:-
hInstFrench = LoadLibrary(_T("LangFRA.dll"));<br />
LoadString(hInstFrench, ID_TEXT, lpBuffer, nBuffSize);<br />
SetWindowText(hWnd, lpBuffer);
I hope this helps. This is one solution there are many others.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
thanks Ted... let me try your method first! ah! one more question, does it work on win98? or, a win2k without select French, German in regional setting?
thanks,
jim
|
|
|
|
|
Yes it should do work on 98/win2k, you would need to check on the regional setting of the PC and select the language DLL to use if you want to select a language automatically, my demo prog will show you what I mean.
e.g. if your default language is English a user in France, on the German border, would automatically get French, assuming a French resource DLL exists! if the PC was French, but if the user was German, they may prefer to work in their own language, so they would have to select the language to be German via the menu.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
i found strange problem actually i occurred b4.
the problem is, in win2k, i selected several regional fonts and set one as the default. for example, i set english as default and selected french in regional settings as well. then, in your application, i switch to french. the text in menu can be displayed properly but not the text in dialog box and background view.
this problem also occurred in my application which have single language. foe example, my app. is in traditional chinese. when i switch to simplified chinese as default and selected simplified chinese in regional settings. the trad. chinese menu can display correctly... but, dialog failed!
do u know the reason?
thanks,
jim
|
|
|
|
|
The dialog box should not be a problem, IF it is defined in relevant language DLL.
Some elements, you will need to update manually, such as the status text in the staus bar, i.e. change "Ready" to "Gotowy" in Polish.
These will normally update once Windows has forced a repaint or the text changes.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Ted, i think you don't understand my question...
i have captured several screenshoot in the below link...
you may get it after read them.
http://ux.aiib.net/~chaze/sctc.html
pls give me some idea!
thanks,
jim
|
|
|
|
|
there are lots of issues here like mbcs vs unicode either ucs16 or rtf8.
as long as you are sticking with nt / w2k / xp use unicode
win95 / win98 will be painful.
The font selected for the dialog / controls needs to actually have gylphs for the unicode characters you are trying to display in the language you are trying to display them in. its not enough to simply use the correct unicode chinese character you also need to have selected an appropriate font.
note most 'foreign' fonts will have at least the first 128 / 256 ascii / ansi gylphs in them as well for english.
|
|
|
|
|
My printf statement isn't giving me the expected results. Can anyone see where I am going wrong here? Thanks, Joanne
void LogFormattedMessage(char * sMessage, ...)<br />
{<br />
va_list ap;<br />
va_start(ap, sMessage); <br />
<br />
<br />
TCHAR sFormattedMessage[500];<br />
_stprintf(sFormattedMessage, sMessage, ap);<br />
va_end(ap); <br />
<br />
...<br />
}
|
|
|
|
|
I'm not sure exactly what stprintf does, but it appears to be a variant of sprintf for TCHAR's. To use var args you need one that takes a va_list - have a look at vsnprintf
|
|
|
|
|
Thanks, that function works properly.
(stprintf is just the tchar routine for sprintf)
Cheers, Joanne
|
|
|
|
|
I need some programming advice to a specific problem I am having in my app. I have a bunch of owner-drawn buttons on the main window, all of which work with a tooltip through a hook. I have subclassed the windows to receive the WM_LBUTTONDOWN and WM_LBUTTONUP messages. When the user clicks on the button a "push" is simulated through InvalidateRect and through BitBlt in WM_DRAWITEM a new bitmap is painted when the mouse button is pressed down and then the button is repainted upon WM_LBUTTONUP. All this works fine expect when the tooltip is showing. I am thinking it has something to do with the hook. Does someone have a workaround for this. Here is the code to the hook procedure:
<br />
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)<br />
{ <br />
if (nCode < 0) <br />
return CallNextHookEx(cSkinObject.hMsgHook, nCode, wParam, lParam); <br />
<br />
switch ( ((MSG*)lParam)->message ) <br />
{ <br />
case WM_MOUSEMOVE:<br />
case WM_LBUTTONDOWN:<br />
SendMessage(hwndTool, TTM_RELAYEVENT, 0, lParam);<br />
<br />
break;<br />
<br />
default: <br />
<br />
break; <br />
} <br />
return CallNextHookEx(cSkinObject.hMsgHook, nCode, wParam, lParam); <br />
}<br />
<br />
Thanks in advance.<br />
|
|
|
|
|
SendMessage?
Try to use Postmessage.
The problem might be, that SendMessage does not return, until the message is processed.
G. Steudtel
|
|
|
|
|
Hello Im very new to windows proramming. I have a very basic question and thank you in advance for spending time to answer it.
I created a standard Dialog Box thru Appwizard (VC++ 6.0).
I need to use a function that needs the boxs' handle as the first parameter
where can I find this? I look on InitInstance and the construcor but I cant seem to find where the member variable is.
please help.
Thank you again
|
|
|
|
|
|
|