|
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."
|
|
|
|
|
|
The only build-in way to run an exe on another NT/2k/XP machine is to register it as NT service (CreateService()) and then call StartService() to run it.
However, your exe should be graceful to SCM and behave like a service, else StartService() would return an error and the event log get's clutterd with error messages. However, that's not really much work to do.
Next point to consider is who should be able to run the thing. Services have an DACL which controls who is allowed to start and stop them. You can find a tool to change a service DACL (it's called "scacl.exe" and part of my LS-Tools freeware collection) on my homepage.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
I'm working on view that should display some graphic charts.
I've derived my view from CScrollView.
Is it possible to change size of horizontal scroll bar of view: i want insert some buttons in bottom-right corner of view.
thanks in advance.
nobody is perfect
|
|
|
|
|
To do this you will have to replacethe standard scrollbars used by the scrollview, Add 2 CScrollBar controls to your inherited view, create them and override the GetScrollBarCtrl() virtual base class function, and return the correct pointer for SB_HORZ and SB_VERT.
I think that is the first step in doing what you want!
Roger Allen
Sonork 100.10016
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals. - Chris maunder.
You can tell from his picture he doesn't sleep, and what kind of things does he weave?
|
|
|
|
|
I have a COM smart ptr (IMessagePtr) and I would like to keep a vector of them. Is it advisable to make a vector<IMessagePtr>?
I am a bit weary of STL with smart pointers. Does anyone know of any issues with the above vector?
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
If i'm not wrong you need to use the ATL Class CAdapt to return the adress of the ptr itself and not of the smartptr like this:
vector<CAdapt<IMessagePtr>> x;
Cheers,
Joao Vaz
A Programming Language is a tool that has profound influence on our thinking habits -The late giant Edsger Dijkstra 1930 - 2002
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary. -
|
|
|
|