|
Hy Jerome,
thanks in advance for your support!!
No, or better I think not.
Because I observed this behaviour sometimes.
I create a ATL wizard project, simply dll without MFC support,MTS etc...
After that I add a simple object with ATL wizard, and after again I add a method.
Since I compile this project on order to obtain a simple dll and seems all fine.
When I import the library with #import ....\<name>.tlb no_namespace in other project and try to compile appear the famous error!!
I believe that depend by some setting in my Visual Studio but I'm not sure!!
Bye;)
Andrea
|
|
|
|
|
I know this may seem like a rather simple problem, however it has stumped. Any help would be greatly appreciated.
How are child controls (CEdit, CButton, etc) resized when the window is manually resized or maximized? (I know that all controls are endowed with the ability to redraw themselves, however if I maximize or manually resize the frame window how do I stretch the control either horizontally or vertically so that I am not left with lots of empty space in the window?)
Thanks,
Don
|
|
|
|
|
Alas,
MFC (and Win32 API) doens't automatically support this, you need to do it by hand, on the OnSize(...) handler of WM_SIZE.
There are a couple of ways of doing it, either you manually resize and reposition each control, or you use one of many solutions presented here on codeproject, search for them in the dialog section.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
One solution is to override OnSize() and move the objects accordingly via MoveWindow() and SetWindowPos().
Kuphryn
|
|
|
|
|
I spawned a modeless dialog from my view class. It debug asserts or crashes in release:
BOOL CMsg::OnInitDialog()
{
CDialog::OnInitDialog();
m_nTimer =SetTimer(1,4000,0);
return TRUE;
}
void CMsg::OnTimer(UINT nIDEvent)
{
DestroyWindow();
KillTimer(m_nTimer);
CDialog::OnTimer(nIDEvent);
}
void CMsg::PostNcDestroy()
{
delete this;
CDialog::PostNcDestroy();
}
Switching the order of destroyW and KillTimer doesnt help...Call stack says OnTimer...
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
delete this; CDialog::PostNcDestroy();
Rethink the order. In 2 lines above you delete an object and then you call a method on that object
|
|
|
|
|
aaargh! I see ....
I was also being blind in the OnTimer function...destroying a window and trying to process it....
Hope I learned from this lesson!!!
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
Hope I learned from this lesson!!!
That's the difference between the idiot and the smart. Both make mistakes, but only the smart learns something out of it.
--
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
The drag and drop using "DragAcceptFile" do not produce results...
the code that I use is :
void dragDialog::OnDropFiles ( HDROP hdrop )
{
AfxMessageBox ("Done");
}
but the messagebox is not displayed when i drag and drop a file on the dialog.
Is needed a register method to do this ?
Can everyone help me sending me a small code ?
redlion@freemail.it
tank you
|
|
|
|
|
can anyone give me a sample of how to receive a UDP Packet using recv() call.
i have a criteria that i don't want the usual recvfrom() call but instead want to use the recv call.
any suggestions appreciated....
|
|
|
|
|
How can i place a dialog as a control on another dialog ??? We can place buttons on a dialog, similarly i want to place another dialog on a parent dialog ????
|
|
|
|
|
You can use property pages for this
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
benjymous wrote:
You can use property pages for this
Uh ? You mean property sheets and pages ?
He means adding sub-dialog to parents dialog, like adding complex components to another dialog.
You can't do it with the resource editor, you need to create them manually and place them in yout parent dialog.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Yeah, that's exactly what I've meant
I've used property pages in the past to be able to show and hide groups of controls on multiple pages. You can automate it to a certain extent by placing a frame on the parent dialog in the resource editor and then querying it's size and position when displaying the child dialog on top
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Yep, I understand now what you mean.
That's the way it usually done when placing "Components" dialogs inside other dialogs.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Specify the DS_CONTROL style for the 'child' dialog, and make parent its parent.
Software Zen: delete this;
|
|
|
|
|
I want to change the text of the statusbar inside an MDI application created with the appwizard. m_wndStatusBar.SetWindowText(text);
Now, running this, the text will not change. But, if you show a messageBox after that, the text will change. So, probably it is some sort of update/validate thing I have to do after the SetWindowText. I tried UpdateWindow(), but that's not it.
What is the function to force that?
using: [VISUAL STUDIO 6.0] [WIN98/2]
|
|
|
|
|
Maybe m_wndStatusBar.SetPaneText(0, text) works better...
rechi
|
|
|
|
|
I have been reading Michael Dunn's article about Custom Draw and the List Control to figure out how to change the background and text color to change on a selected item. I have tried the code below in both the pre and post paint stages. Also in both stages I have tryed returning both CDRF_DODEFAULT and CDRF_SKIPDEFAULT, either nothing happens.. or no selection highlight is drawn.
Anybody have any ideas? I'm lost with Custom Draw.. I don't understand why I can change the text/bk color for every item.. but if I test for a selected item, and then try and change the text/bk color.. nadda.. nothing .. zip..
<code>
void CPlayListWindow::OnCustomDrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = 0;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
*pResult = CDRF_NOTIFYITEMDRAW;
else if(CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYPOSTPAINT;
}
else if(CDDS_ITEMPOSTPAINT == pLVCD->nmcd.dwDrawStage)
{
LVITEM rItem;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
ZeroMemory ( &rItem, sizeof(LVITEM) );
rItem.mask = LVIF_IMAGE | LVIF_STATE;
rItem.iItem = nItem;
rItem.stateMask = LVIS_SELECTED;
GetListCtrl().GetItem(&rItem);
if(rItem.state == LVIS_SELECTED)
{
pLVCD->clrTextBk = RGB(0,0,255);
pLVCD->clrText = RGB(0,0,255);
*pResult = CDRF_SKIPDEFAULT;
}
}
}
</code>
C# a poor attempt at bringing C++ to the VB masses
|
|
|
|
|
I have been working from the same article just yesterday. Hers a copy of mu OnCustom draw...
void CCommunicationView::OnCustomDrawLog(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW *pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
*pResult = CDRF_DODEFAULT;
if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if ((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage)
{
int item = pLVCD->nmcd.dwItemSpec;
LVITEM rItem;
ZeroMemory(&rItem, sizeof(LVITEM));
rItem.mask = LVIF_IMAGE | LVIF_STATE;
rItem.iItem = item;
rItem.stateMask = LVIS_SELECTED;
m_Log.GetItem(&rItem );
int value = m_Log.GetItemData(item);
CDC* pDC = CDC::FromHandle ( pLVCD->nmcd.hdc );
CRect rcText;
CRect rcIcon;
CString text;
m_Log.GetItemRect(item, &rcIcon, LVIR_ICON);
m_Log.GetItemRect(item, &rcText, LVIR_BOUNDS);
rcText.left += rcIcon.Width();
text = m_Log.GetItemText(item, 0);
if (rItem.state & LVIS_SELECTED)
{
pDC->SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
CBrush brush(GetSysColor(COLOR_HIGHLIGHT));
pDC->FillRect(rcText, &brush);
}
else
{
pDC->SetTextColor(value);
CBrush brush(GetSysColor(COLOR_HIGHLIGHTTEXT));
pDC->FillRect(rcText, &brush);
}
pDC->DrawText(text, rcText, DT_END_ELLIPSIS | DT_EXPANDTABS | DT_SINGLELINE | DT_VCENTER);
pLVCD->clrText = value;
m_ilLog.Draw(pDC, rItem.iImage, rcIcon.TopLeft(), ILD_TRANSPARENT);
*pResult = CDRF_SKIPDEFAULT;
}
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Thanks for the quick reply. I got it working.. but I am still confused. I don't understand why I have to draw it out in the pre paint stage. Post paint I might be able to understand.. but I don't understand why I can loop through message for each Item, and change there colors using nmcd.clr...() but I can't check if the item is selected and use mncd to change color?????
C# a poor attempt at bringing C++ to the VB masses
|
|
|
|
|
Hi,
Stupid question perhaps but I want to create a component in MFC and I can't figure out how. The component I want to create is for a simulator of embedded software. The components are for example an AC-Motor. The Motor control has to be a rectangle containing a checkbox to enable/disable the overheat sensor another checkbox to enable/disable the state of the motor and a picture displaying a rotating icon indicating that the motor is running.
In a machine there are perhaps 20 motors. I want to create 20 instances of the control at run time. How should I create such a control? What class should I derive from and what events should I use. Maybe I need to create an ActiveX component????
Pleas help me getting started. Thanks in advance
PS. I have done dialog applications only till now.
|
|
|
|
|
Only another idea...
Why don't you create a dialog that contains all that stuff and then creates it as a control wherever you want to?
You could control all the controls and interact with whatever you want...
And then the only thing to do would be to create different instances of that dialog as a control...
You could even place some static texts in your dialog editor and then assign their ID and position to your newly created dialog... (if you do that, remember to destroy the Static control after having linked it's ID/position to your newly created dialog...)
Hope this helps...
|
|
|
|
|
Thanks,
This works for me!
Dennis
|
|
|
|
|
1) Yes you could create an ActiveX control. Just follow the documentation in any MFC book for creating an ActiveX control.
2) However I suggest you just take the easy way out: Put 20 instances of the CAnimateCtrl on your dialog, add the check boxes and you done. Or you could create them at run time in a for loop specifying the positioning if you want to. The whole thing should be up and running in 2 hours at the most. It sounds like a fun little project. Just remember if you use the CAnimateCtrl you must provide an AVI of RLE-8 format. But that's easy.
3) As an alternative and if you are using MFC 7 you could derive your Dialog from CDHTMLDialog instead of CDialog and build up an HTML page to display. MFC 7 support allows a very smooth interface with the HTML page and your code: far easier than manually embedding a Webbrowser control in the dialog as is done in MFC 6.
I wish I had your job.
Art
|
|
|
|