|
Vissu89 wrote: and based on the Client message post a message to get the required data.
i dont understand why u worry about the child window type. u can get the font of any window using the function GetFont() or the message WM_GETFONT.
nave
|
|
|
|
|
let me make my problem more clear.
I want to know the Edit properties of the Client Area of the Window(the edit classproperties)
If i use WM_GETFONT for the Window (let say notepad), then it will give
the system default font which is of no use if i want to know the font properties
of the Client area where the user is typing.
I could get the Edit properties of the Notepad by using the above same procedure,
but in other applications i could not corelate the class name hat has this Edit
properties.
Please reply.
Thanks
|
|
|
|
|
sorry still i dont get u.
By enumerating all the childs, u can get the pointer of each child window. then sending the WM_GETFONT to this child window, u can get the font. Isn't? if u want to get the font properties of edit windows only, Take the class name of the window using the GetClassName() function and compare if it is "Edit" (WC_EDIT).
nave
|
|
|
|
|
You are right, i agree.
That's what i am doing. but the issue is i am getting the match for "Edit" class
only for Notepad application but not windows wordpad or Ms Word kind of editors.
Is there any generic way to do this.
Thanks,
Vissu.
|
|
|
|
|
|
Wordpad uses a RICHEDIT50W window class.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I remember that an article is in codeproject that with it you can find detaily in programs like classes,controls and....
|
|
|
|
|
hi all,
iam trying to receive data from usb in my mainframe.cpp file where the usb read is done as a separate thread. i want to reformat the received buffer and pass this buffer to a WM_PLOT function which is in projview.cpp file and inside plot function i use this buffer to plot the function.
the trouble iam facing is this buffer has to be very large ie., the buffer that is used to receive the data from usb has to be 3000000 bytes long. hence, the reformat buffer has also to be that big.
how do i create the buffer? can anyone show me some code snippet to do the above method. to create such big buffers, i tried using unsigned long* buf = new unsigned long [3000000];
but if i create the reformat buffer as such, i need to delete it as well but i need to pass this buffer on to projview.cpp file, then how will i do it? where will i delete it?
is there a better way of doing it? i desperately need help.
Thanks in advance.
|
|
|
|
|
thathvamsi wrote: but if i create the reformat buffer as such, i need to delete it as well but i need to pass this buffer on to projview.cpp file, then how will i do it? where will i delete it?
Firstly, if your buffer needs to be 3000000 bytes long, then you need
unsigned char* buf = new unsigned char[3000000]
otherwise you're overallocating by a factor of 4.
Secondly, passing the buffer around should be no problem, since you just need the address (and possibly a size, to help detect/prevent underrun/overrun).
From your post, you need two buffers; the first is used by the thread reading the data. Does this thread also perform the reformat? Can the reformat be done 'in place' or do you need a separate buffer?
Only you know when to delete the buffer - when you're done with it. However, don't keep deleting and reallocating it, since they are potentially expensive (and fragmenting) operations.
Steve S
Developer for hire
|
|
|
|
|
[edit]
I've found that the underlying problem is problem is in the call to DDX_DHtml_Radio in DoDataExchange. The underlying MFC code queries IHtmlElementCollection, which consistently returns NULL. Because of this, the code assumes that the radio button is not in a group and subsequently exits without updating values.
I've seen one comment on the net compaining that IHtmlElementCollection stopped working on XP SP2 (my environment), but I can't find any confirmation that it's a known issue. In any event, the failure to obtain this interface pretty much takes the wheels off the wagon. Any ideas, anyone?
[/edit]
With CDhtmlDialog in VS2003, Class Wizard doesn't appear to support adding member variables wired up to the dialog controls like the CDialog stuff I'm used to. Trying to find sufficient documentation to do it manually has been an all day and fruitless search. The online documentation appears to stop at "here's the class members." No overview on how to stitch it all together.
I naturally searched the CP articles first, but they're all doing various kinds of rocket science and none of the simple stuff. All I need to do is the basic old fashioned dialog stuff, but with an html layout. Add some edit controls & radio buttons, initialize their values in OnInitDialog() and grab their values after DoModal() completes. I mean, how hard could this be?
Does anyone know of any documentation / tutorials anywhere that describes how to do the basic stuff with the html dialog class? I've hit everything from Google to MSDN to CP to VS online help and can't seem to find any straightforward documentation on the basics. I'd be most grateful for any educational resources you might point me to.
The hard stuff is easy, and the easy stuff chews up an entire day...
-- modified at 11:30 Wednesday 30th August, 2006
|
|
|
|
|
Have you had a look at the MSDN example? [^]
SkyWalker
|
|
|
|
|
Hi, Mircea.
Thanks for taking the time to help on this. Yeah, that was one of many samples that I downloaded & reviewed to no avail. Specifically, here's the problem I'm fighting. I have an edit & two radio buttons in the htm. DoDataExchange updates the variable for the edit, but not the radio buttons. The button state is never updated based on the value of the radio variables, and the value of the variables never changes throughout the life of the dialog.
Here's the relevant snippets for the radio buttons in .htm and DoDataExchange:
<br />
<INPUT id="btnFarenheit" type="radio" name="RadioGroup"> Farenheit<br />
<br><br />
<INPUT id="btnCelcius" type="radio" name="RadioGroup"> Celcius<br />
void CDlgSelectLocation::DoDataExchange(CDataExchange* pDX)<br />
{<br />
DDX_DHtml_ElementValue(pDX, _T("edtLocation"), m_strLocation); <br />
DDX_DHtml_Radio(pDX, _T("btnFarenheit"), m_lFarenheit);<br />
DDX_DHtml_Radio(pDX, _T("btnCelcius"), m_lCelcius);<br />
<br />
CDHtmlDialog::DoDataExchange(pDX);<br />
}
m_strLocation behaves exactly as expected, but the radio buttons don't. As far as I can tell, I'm making the analgous calls for the radio buttons as the MSDN example uses for the checkboxes, but clearly I'm missing something here.
Of course, first and foremost I'd like to solve the problem at hand. However, it would also be great if I could find the FM to RT regarding the html dialog. I can't seem to find a general usage or tutorial on it anywhere.
As a secondary question, is it normal that you can't use Class Wizard to generate this code for an html dialog? In a CDialog implementation this sort of thing is trivial and quickly done via wizard (although I'd still like to understand the underlying code).
Anwyay, that's the scoop. If anyone has insights on why the radio buttons aren't behaving properly it would be most appreciated. And pointers to the FM would be great as well.
Thanks again, man.
|
|
|
|
|
Wouldn't be the two radio buttons grouped, so that a value of 0 corresponds to the first and a value of 1 corresponds to selection of the second?
SkyWalker
|
|
|
|
|
Not sure I follow you. The buttons behave properly as a group in the UI, i.e. after selecting one you can arrow back & forth to switch selection, etc.
As for the value of the radio variables, they never change throughout the lifetime of the dialog. If I initialize them with 0, 1 or 123456798, that's what they exit the dialog with. Am I missing something?
|
|
|
|
|
Discussions around the topic are still under way.
I do not remember exactly, but at some point in time, I had to to add the WS_GROUP attribute to all the radio buttons, create all the variables, then I had to remove the WS_GROUP attribute from all but the first radio
button. Do not ask why. I cannot explain. It just happenned like that. After that, it worked properly.
A lot of my friends say it is an ancient design bug, and it has been around as long as Visual Studio has existed. There are signals that actually VS7 propagates that behaviour.
Long story short: try to do what I did, then share ... your experience
SkyWalker
|
|
|
|
|
I understand what you mean, but WS_GROUP is a window style, and I'm using html in the associated .htm file to create the controls rather than the CDialog oriented method that uses the .rc file.
If this was a CDialog, I could have implemented it faster than it took me to type the messages.
Apparently the html dialog is voodoo - I can't seem to get much info on it anywhere, and folks here don't seem to be familiar with it, either...
|
|
|
|
|
Promise to keep an eye on the topic
SkyWalker
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Hi, Whitesky.
I appreciate the link, and it looks like cool stuff. However, the problem I'm looking to solve is getting the data member variables updated in DoDataExchange. If you have any insights on that, they would be most appreciated.
Thanks,
|
|
|
|
|
|
Hi,
When I insert a button on a toolbar (OnCreate & OnSize) it shows as it should. However, after the call to OnPaint() where I do some painting on the client area of the toolbar, the button disappears. It is still there (I can click on it), but it is not showing. I tried clipping the client region so that it did not overlap the button rectangle, but... Also, I tried
::SendMessage(m_hWnd, TB_HIDEBUTTON,FALSE,FALSE);
inside the OnPaint() - BeginPaint(), but did not work either.
Anyone?
Tanx in advance,
Murillo
|
|
|
|
|
Try ModifyStyle( 0, WS_CLIPCHILDREN )
- NS -
|
|
|
|
|
Did not work either. I tried just after creating the button
|
|
|
|
|
Could you show the code snippet?
- NS -
|
|
|
|
|
Hello NS,
I am working on Erik Thompsom's toolbar tutorial (http://www.codeproject.com/atl/ietoolbartutorial.asp).
After making some modifications to Erik's code, I added a static control to the right of the button and managed to change bk color, text color and so on, which happens inside OnPaint()->BeginPaint(). However, after doing this the button doesn't get repainted. It is still there, since it is responding to mouse clicks. I tried many things, from clipping the (m_hWnd) toolbar's client rect so that it wouldn't overlap the button, to trying to paint only the static control (m_ReadWnd) which is a child window for the m_hWnd. I will show you three functions: OnCreate, OnSize and OnPaint.
<br />
LRESULT CMFToolbar::OnCreate(UINT uMsg,WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
SendMessage(m_hWnd, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_MIXEDBUTTONS);<br />
<br />
SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON),0);<br />
<br />
SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 1, 0L);<br />
<br />
TCHAR* pCaption = _T("Cotação - Yahoo Finance");<br />
int iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, 0, (LPARAM)pCaption);<br />
<br />
HICON hMotley = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MOTLEY));<br />
m_hImageList = ImageList_Create(16,16,ILC_COLOR16,1,0);<br />
int iImageIndex = ImageList_AddIcon(m_hImageList,hMotley);<br />
DestroyIcon(hMotley);<br />
<br />
::SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)m_hImageList);<br />
<br />
TBBUTTON Button;<br />
ZeroMemory((void*)&Button, sizeof(TBBUTTON));<br />
Button.idCommand = IDM_GETQUOTE;<br />
Button.fsState = TBSTATE_ENABLED;<br />
Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;<br />
Button.dwData = 0;<br />
Button.iString = iIndex;<br />
Button.iBitmap = 0;<br />
::SendMessage(m_hWnd, TB_INSERTBUTTON, 0, (LPARAM)&Button);<br />
<br />
<br />
RECT rect = {0,0,0,0};<br />
m_EditWnd.Create(m_hWnd, rect, NULL, WS_CHILD|WS_VISIBLE,WS_EX_CLIENTEDGE);<br />
m_EditWnd.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));<br />
<br />
<br />
RECT rect2 = {0,0,0,0};<br />
<br />
m_ReadWnd.Create(m_hWnd, rect2, NULL,WS_CHILD|WS_VISIBLE|WS_EX_CLIENTEDGE);<br />
m_ReadWnd.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));<br />
m_ReadWnd.SetWindowText("Text on STATIC OBJECT");<br />
<br />
<br />
return 0;<br />
}<br />
<br />
LRESULT CMFToolbar::OnSize(UINT uMsg,WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
<br />
RECT wndRect, btnRect;<br />
<br />
RECT fixedRect = {0,0,50,20};<br />
<br />
GetClientRect(&wndRect);<br />
::SendMessage(m_hWnd, TB_GETITEMRECT, 0, (LPARAM)&btnRect);<br />
<br />
SendMessage(TB_SETINDENT,55);<br />
<br />
m_EditWnd.MoveWindow(&fixedRect, FALSE); <br />
<br />
wndRect.left += btnRect.right + 300;<br />
<br />
wndRect.right -= 100;<br />
<br />
m_ReadWnd.MoveWindow(&wndRect, FALSE);<br />
<br />
return 0;<br />
}<br />
<br />
LRESULT CMFToolbar::OnPaint(UINT uMsg,WPARAM wParam, LPARAM lParam, BOOL& bHandled)<br />
{<br />
<br />
PAINTSTRUCT ps, ps2;<br />
HDC hDC = NULL;<br />
HDC hDC2= NULL;<br />
RECT test_rect = {100,100,100,20};<br />
RECT bk_rect = {100,100,100,20};<br />
HRGN hRgn = NULL;<br />
HRGN hRgn2 = NULL;<br />
HBRUSH hBr = CreateSolidBrush(RGB(255,0,0));<br />
HBRUSH hBr2 = CreateSolidBrush(RGB(0,0,255));<br />
<br />
::GetClientRect(m_hWnd,&test_rect);<br />
::GetClientRect(m_ReadWnd,&bk_rect);<br />
<br />
hRgn2= CreateRectRgn(test_rect.right/2,test_rect.top+10,test_rect.right-900,test_rect.bottom-5);<br />
<br />
hRgn = CreateRectRgn(bk_rect.left+200,bk_rect.top,bk_rect.right-100,bk_rect.bottom);<br />
<br />
hDC2 =::BeginPaint(m_hWnd,&ps2);<br />
hDC =::BeginPaint(m_ReadWnd,&ps);<br />
<br />
::SelectClipRgn(hDC2,hRgn2);<br />
::SelectClipRgn(hDC,hRgn);<br />
<br />
::SetTextColor(hDC,RGB(255,255,255));<br />
<br />
::SetBkColor(hDC,RGB(255,0,0));<br />
::FillRect(hDC2,&test_rect,hBr2); <br />
::FillRect(hDC,&bk_rect,hBr);<br />
<br />
::TextOut( hDC, 0, 0, _T("Some Text"),9 );<br />
<br />
::EndPaint(m_ReadWnd,&ps);<br />
::EndPaint(m_hWnd,&ps2);<br />
<br />
<br />
<br />
return 0;<br />
}<br />
If I do not treat the WM_PAINT message, the button appears. If I treat, it does not.
One other thing: you may notice that I have to BeginPaint(..) on both the parent window (m_hWnd) and the child window (m_ReadWnd), although I just want to paint the child. If I don't BeginPaint the parent, IE crashes...
Sorry for the long message. I can send you printscreen images of the toolbar so you can have a better idea if necessary.
Thank you NS
- Mfranco -
|
|
|
|
|