|
Not sure if i need DYNCREATE. I need automation, which MSDN leads me to believe depends on DYNCREATE.
Jon
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Jon Hulatt wrote:
if i try to delete it, i get a compiler error because the destructor in CMyClass is protected (becuase thats what classwizard set it to be; part of the whole DYNCREATE thing).
IIRC, that's a minor bug/feature in the class wizard. You can just change the destructor to be declared public, and voila, problem solved. DYNCREATE doesn't care about the destructor, it just needs a default constructor.
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
I need to set a checkmark on one of the MenuItems in the menu of the CMDIChildWnd in a program based on the multiple document doc/view architecture. How do I do that?
I think I know how to set the check mark I just can't figure out how I get access to the right CMenu? (Untill now I've only managed to get access to the CMainFrame menu)
Hope somone can help
I also committed the crime of posting a programming question in the Lounge.
|
|
|
|
|
You'll need to handle UPDATE_CMD_UI for appropriate command and use CCmdUI::SetCheck. This will result in checkmark next to menu item.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Take a look at CMDIChildWnd::OnUpdateFrameMenu.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Why not just use an update handler (ON_UPDATE_COMMAND_UI) and forget about trying to get hold of the menu item? Update handlers are an easier and clearer way of controlling the state of menu items, and have the added bonus of handling things like toolbar buttons at the same time.
But if you still insist on trying to use the menu pointer, the main reason you're having trouble is that MDI child windows don't have their own menus. Only the main frame window has a menu, it just changes its menu when different child windows are activated.
If you're still interested, have a look at the source code for CMDIFrameWnd and CMDIChildWnd (in AFXWIN.H and WINMDI.CPP), in particular at OnUpdateFrameMenu . The code responsible for swapping the main frame's menu in MDI apps is not very well documented in the MFC docs, but the source code is fairly clear (as far as MFC source goes).
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Hmmm .. I think I wasn't quite specific enough describing my problem.
My problem is this; When the menuItem is clicked a modeless CDialog box is popped up and SetCheck is called to mark the menuItem. If I click the menuItem again the Cdialog box disappears and so does the check mark, I have managed to get that far
Now my problem is that CDialog box itself also has a close button that closes the box but I cant manage to remove the checkmark when the dialog box is closed through this button ... how can I solve that?
I also committed the crime of posting a programming question in the Lounge.
|
|
|
|
|
I'd still tend to use an update handler (probably in your main frame window, but it depends where you can get at the pointer to your modeless dialog from), something like this:
OnUpdateMenuItem(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_pDlg && m_pDlg->IsWindowVisible());
}
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
Hi friends,
I am calling a Dialog Box from a message handler function in my View class. In 'oninitdialog' of the dialog class I want to update this dialog box with some linked list which is declared public in the my View class. I want to access this Linked list and modify in the Dialog class when the user wants any modification. How to access this? Thanks in advance.
|
|
|
|
|
Put a pointer to your view into the dlg class before you call DoModal.
CYourView::OnShowDialog()
{
CYourDlg dlg;
dlg.m_ParentView = this;
dlg.DoModal();
}
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Sorry steen I couldn't get ur answer, I didn't put the question right first time, please see my question. Thanks
|
|
|
|
|
Lemme get this straight: You have a linked list that is a member of your view class. From the view class you instantiate a dialog. In the dialogs OnInitDialog you want to access the linked list.
If this is correct, the my previous answer is still valid. Make a member variable in your dialog class:
class CYourDialog : CDialog
{
....
public:
CYourView* m_pParentView;
}
Initialize the m_pParentView pointer in the view class before calling DoModal on the dialog class:
void CYourView::OnShowDialog()
{
CYourDialog dlg;
dlg.m_pParentView = this
dlg.DoModal()
}
Then you can to access the linked list in OnInitDialog:
BOOL CYourDialog::OnInitDialog()
{
...
m_pParentView->m_LinkedList = ...
}
If I have misunderstood your problem then please rephrase or provide a code snippet illustrating the problem.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks Steen,
I got it.
cheers.
Satya
|
|
|
|
|
When i continuous dump string to the ListBox, it will take up 100% of my CPU usage. Does anybody know how to overcome this problem? Thanks in advance.
|
|
|
|
|
KHYEE wrote:
When i continuous dump string to the ListBox, it will take up 100% of my CPU usage
Well, what else have you expected? What kind of information are you displaying in your listbox?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
In fact, I'm trying to dump a debug print to the the List Box from other programs. May i know what is virtual list box
|
|
|
|
|
KHYEE wrote:
Does anybody know how to overcome this problem?
Don't continuously dump strings into the listbox. If you are storing data internally already, a virtual List Control might work, but that depends a lot on what you're doing / trying to accomplish.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
In fact the data is dumped to the list box by other external program and depend on how busy is the external program. If the external program is very busy, the list box will get the 100% CPU usage. Any other ways to solve this problem? Thanks
|
|
|
|
|
Well, if you've only got so much CPU, then you've only got so much CPU... But one thing you might try is using a separate thread to collect data, and then using a lower-priority thread to actually display it. It wouldn't have to update constantly, but when it did it could add several items at a time and gain efficiency that way. There's probably no simple solution, i'm afraid.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
I've created a MFC dialog based application with a RTF control and i want to insert a bitmap image in it. Using this code:
void CImageDataObject::InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap)
{
SCODE sc;
CImageDataObject *pods = new CImageDataObject;
LPDATAOBJECT lpDataObject;
pods->QueryInterface(IID_IDataObject, (void **)&lpDataObject);
pods->SetBitmap(hBitmap);
IOleClientSite *pOleClientSite;
pRichEditOle->GetClientSite(&pOleClientSite);
IStorage *pStorage;
LPLOCKBYTES lpLockBytes = NULL;
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &pStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
lpLockBytes = NULL;
AfxThrowOleException(sc);
}
ASSERT(pStorage != NULL);
IOleObject *pOleObject;
pOleObject = pods->GetOleObject(pOleClientSite, pStorage);
OleSetContainedObject(pOleObject, TRUE);
REOBJECT *reobject=new REOBJECT;
ZeroMemory(reobject, sizeof(REOBJECT));
reobject->cbStruct = sizeof(REOBJECT);
CLSID clsid;
sc = pOleObject->GetUserClassID(&clsid);
if (sc != S_OK)
AfxThrowOleException(sc);
reobject->clsid = clsid;
reobject->cp = REO_CP_SELECTION;
reobject->dvaspect = DVASPECT_CONTENT;
reobject->poleobj = pOleObject;
reobject->polesite = pOleClientSite;
reobject->pstg = pStorage;
pRichEditOle->InsertObject(reobject);
delete reobject;
pOleObject->Release();
pOleClientSite->Release();
pStorage->Release();
lpDataObject->Release();
} from the primary thread works ok; but from a worker one it inserts a white bitmap.
Do you know what's wrong and what should i do?
rechi
|
|
|
|
|
How to ensure that CBitmap object will be created with 24bpp and it will stay that way when I use LoadBitmap?
In typical API I would use the CreateDIBSection to create a 24bpp bitmap and I could freely access it's bits. But there is no such function in MFC.
Do I have to use these API functions, or is there any "nice" way to do that with MFC classes?
Some additional information:
My code goes like this:
CPoint Point;<br />
CBitmap Bitmap;<br />
Bitmap.LoadBitmap(IDB_BITMAP);
Then I use my own function that converts colors in 24bpp images:
ConvertBitmapColors(Bitmap);
And I draw it on the screen;
dc.DrawState(Point,Bitmap.GetBitmapDimension(),&Bitmap,DST_BITMAP | DSS_NORMAL);
(dc is of course a CPaintDC object)
Finally:
Bitmap.DeleteObject();
The IDB_BITMAP resource is 24bpp bitmap, but the Bitmap object loads it with current desktop's color depth.
I need some way to have an 24bpp bitmap, cause I want to make that color conversion before I draw it.
[ CoY0te ]
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
I have solved that problem by coding my conversion this way:
<br />
CDC * pdc;<br />
CBitmap * OldBitmap;<br />
<br />
pdc=new CDC;<br />
pdc->CreateCompatibleDC(NULL);<br />
OldBitmap=pdc->SelectObject(Target);<br />
<br />
pdc->GetPixel(Point)<br />
...<br />
...<br />
pdc->SetPixelV(Point,Color)<br />
<br />
pdc->SelectObject(OldBitmap);<br />
pdc->DeleteDC();<br />
delete pdc;<br />
It works allright, but only because these images are small (9x15). Using GetPixel / SetPixelV is kinda slow i guess.
It would be better to have a direct access to 24bpp image, but I haven't figured out how to load a resource into CBitmap object as 24bpp image every time.
If someone has any better idea to do it faster without writting a bunch of code, then let me know please.
Greetings.
[ CoY0te ]
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
Did you look at Chris's DibSection class?
As my daughter would say, "... Whatever!"
|
|
|
|
|
I'm looking for a solution to start an EXE-file, which exist on other network-PC.
I've tried to work with the "_spawnv( nOption, prog, args )" function, this works ok when the EXE-file is on the same PC, but doesn't work when the EXE-File exist on other PC.
If anyone has a solution or a suugestion, I would be glad for a short response!
Thanks a lot
Ralph
|
|
|
|
|
You could try using DCOM or RPC
"Hey man, Taliban, Tali me Banana."
|
|
|
|