|
Another guess: maybe your event handler is being called from a different thread than your main window belongs. A possible fix could be that the event handler sends a user message to the main window (say WM_HANDLE_EVENT ) and then doing the popup menu stuff in OnHandleEvent (which executes in the right thread). Maybe it's worth a try.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I need to export C++ objects out of a DLL. The objects don't have to be used outside of the DLL, they just have to be able to be passed back in to the DLL for use inside - essentially, they are containers for the DLL's state.
These objects would never be shared between threads or processes.
I was thinking this might be a way to do it:
typedef HGLOBAL HMYOBJ;
HMYOBJ GetDLLObject()
{
HGLOBAL hObj = GlobalAlloc(GPTR, sizeof(CMyClass));
CMyClass *pClass = (CMyClass *)hObj;
pClass->Init();
return (HMYOBJ)hObj;
}
...
BOOL UseDLLObject(HMYOBJ hObj)
{
CMyClass *pClass = (CMyClass *)hObj;
return pClass->DoSomething();
}
void DestroyDLLObject(HMYOBJ hObj)
{
CMyClass *pClass = (CMyClass *)hObj;
pClass->CleanUp();
GlobalFree(hObj);
}
...
HMYOBJ hObj = GetDLLObject();
BOOL ok = UseDLLObject(hObj);
DestroyDLLObject(hObj);
Does that seem reasonable? It does seem to work, I just wanted someone else to look at it.
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Does that seem reasonable?
It looks very reasonable to me except for one thing. IMHO instead of
HGLOBAL hObj = GlobalAlloc(GPTR, sizeof(CMyClass));
CMyClass *pClass = (CMyClass *)hObj;
pClass->Init();
return (HMYOBJ)hObj;
it's simpler to write
CMyClass *pClass = new CMyClass();
return (HMYOBJ)pClass;
which works just the same.
If you want to take extra precautions to make sure that the object passed back from the user app is a valid pointer, you can have an internal table of pointers and pass an index to that table, instead of the actual pointer --that's how Win32 does it most of the time.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Dear all,
Would you please help me with subj. I want to send defenite packet by means of Winsock2, and destination is MAC address not IP address. But I haven't found how I can do that by using WS2. Is it possible to resolve this prolem?
And if it possible to do in this way, could you ask to me, how I can create packet with required to me structure.
Thanx in advance
RomaDo
|
|
|
|
|
I don't think you can do that.
The IP network that you are transmitting traffic, uses the IP address to route the traffic. If there's no IP address, it won't know where to go.
Regards
-p
|
|
|
|
|
Yeah I gave inaccurate information. I would like to send packet on the mannear of ARP protocol, which would turn on computer in my internal network (192.168....). Simply to say i want to use Wake-up on LAN function. Is it possible to do with VC++ tools and in particularly with using WSock 2?
Thanx for your time
|
|
|
|
|
In Platform builder (3.0), I created a CEPC based WinCE OS which I want to download on a Laptop (Toshiba Tecra 8000) by using the parallel port since the laptop does not have the required CE-Debug compatible ethernet card. the "loadcepc.exe" programs always fails with:
"
Sending boot packet: aa
WaitForStatus: PPSH Disconnected
"
I am able to start a release build of the WinCE OS (Kernel debugging disabled) after I copied the nk.bin file over to the target.
However a debug build always resets the machine.
Is there something wrong (not standard) with the parallel port of the Laptop?
Hints and tips receive a warm welcome.
BR,
Gert.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
never mind, I just figured out I need a special parallel cable, which my collegue manufactured while burning his fingers with the solder...
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
Hi,
I´m running and Ms Word instance in-place, but if I fail to create it ( for example when there is one instance of Ms Word running but unstable), it shows an ugly exception message from word ( then If the user presses ok, my program will continue and it will create the embedded solution), that message is shown in:
pItem->CreateNewItem(clsid);
Is there anyway to avoid that the message is shown to the user ?
Thanks, Bye !
Braulio
|
|
|
|
|
I would like to create a sort of library of method in vc++ to be used in excel. So i believe that if i create a .dll application instead of a .exe, i would be better. But i have read that i could use especially OLE Automation for that kind of application. I have read in msdn the comexcel sample, but it's not really what i want to do.
In fact, i would like that the methods defined in first in vc++ could be used in excel as we could to simply when we create functions in vba. So how we could do that? Where could i find samples?
thanks in advance for your answers.
gerald
|
|
|
|
|
Hi,
A very good doc is: "Automating Microsoft Office 97 and Office 2000" ( written by Lori Turner , 17 February 2000), it´s free you can search for it in MSDN in the web or the cd.
You can find a lot of help in MSDN, just search for this keywords:
kbAutomation kbExcel kbMFC sample
But anyway you are right most of the samples are made for VBasic, but it´s easy to transform it to VC code.
About docs explaining more on Word Automation:
http://www.codeproject.com/com/xoffice.asp
and in codeguru ( www.codeguru.com) you can find some help as well.
Some more samples you can find in the Kruglinski, Shepher, Wingo book "Inside Visual C++".
And one more tip... sometimes the easiest way to find how to implement something for Excel or Word is just to record a macro and see the code generated in VBA.
Good Luck
Braulio
|
|
|
|
|
the Document is a CompoundFile ( include: ole, image file, ... )
-----------------------------------------------------------
I can open or save Document( 1: CMyDoc::Serialize)
but how can I load file to CMfSet Directly ( 2: CMfSet::Open )
1. -----------------------------------------
void CMyDoc::Serialize(CArchive& ar)
{
// m_curMfSet is member var of CMyDoc : ( CMfSet m_curMfSet; )
m_curMfSet.Serialize(ar);
COleDocument::Serialize(ar);
...
};
2. -----------------------------------------
class CMfSet : public CObject
{
DECLARE_SERIAL(CMfSet)
public: // consturct or disconturct
CMfSet();
~CMfSet();
public:
BOOL Open(LPCTSTR lpszFilename);
// ...
};
BOOL CMfSet::Open(LPCTSTR lpszFilename)
{
CFile f;
if( !f.Open( lpszFilename, CFile::modeRead) )
return FALSE;
TRY
{
char buf[4096];
CArchive ar(&f, CArchive::load, 4096, buf);
Serialize(ar);
// It is sure error, but I don't know how correct it
}
CATCH_ALL(e)
{
return FALSE;
}
END_CATCH_ALL
return TRUE;
};
Thank you!
|
|
|
|
|
I had solved it:
CRuntimeClass *pRuntimeClass = RUNTIME_CLASS(CMyDoc);
CMyDoc *pDoc = (CMyDoc *)(pRuntimeClass->CreateObject());
if( pDoc->OpenDocument(lpszFilename) )
pSet->FromOther( pDoc->GetMfSet() );
delete pDoc;
...
------------------------------------------------------
any advance soultion?( if you have time, please tell me the answer)
Thank you!
|
|
|
|
|
is there anybody who ever get this trouble ?
look:
(if u want to see the question directly ,or
save ur time plz go to the end of the thread!)
i create 2 dialogbars in my SDI app. each dialogbar
has a class (i.e. CMyDialogBar1,CMyDialogBar2) ,
and i add 10 buttons in both of the 2 dialogbars.
firstly, i implement one of them.(segment of mainfrm.cpp)
"mainfrm.h"
//////////////////
CMyDialogbar1 m_b1;
CMyDialogbar2 m_b2;
//////////////////
"mainfrm.cpp"
//////////////////
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!m_b1.Create(......))
{
......
}
if (!m_b2.Create(......))
{
......
}
}
//////////////////
**** 0 error after press F7 ! and the 2 dialogbars are all right!
secondly, in "CMyDialogBar1.cpp" ,i init all button in dialogbar1
like this:
//////////////////
BOOL CMyDialogBar1::InitButtons()
{
int i;
for(i=0; i<button_number; i++)
="" {
="" m_btn[i].mydrawbuttonfacefunction(i);
="" m_btn[]="" is="" a="" instance="" of="" cmybutton="" class=""
="" deriving="" from="" cbutton="" class,but="" cmybutton
="" can="" change="" the="" color="" button
="" m_btn[i].subclassdlgitem(idc_bar1_btn1+i,="" this);
="" }
="" return="" true;
}
=""
all="" these="" buttons="" in="" cmydialogbar1="" are="" set="" to="" ownerdraw="" style="" ,="" and="" i=""
make="" drawitem()="" function=""
****="" 0="" error="" after="" press="" f7="" dialogbar1="" got
="" different="" each
now,="" am="" going="" implement="" button="" on="" second="" dialogbar.
="" then="" trouble="" comes="" out.
i="" add="" such="" message="" handle="" "mainfrm.cpp"
i="" place="" code=""
in="" "mainfrm.cpp"="" ,(here="" segment)
=""
begin_message_map(cmainframe,="" cframewnd)
="" on_command_ex_range(idc_bar2_btn1,idc_bar2_btn10,onbar2lbtn)
end_message_map()
=""
in="" “mainfrm.h”
="" {{afx_msg(cmainframe)
="" afx_msg="" void="" onbar2btn(uint="" btnid);
="" }}afx_msg
=""
all="" implemented="" ,but="" some="" we="" create="" first="" disabled="" !="" why="" ??
when="" remove="" implementing="" dialogbar(dialogbar2),="" 1st="" dialogbar(dialogbar1)="" enabled.="" cant="" figure="" out="" what="" worng.="" maybe="" make="" mistakes="" using="">=2 dialogbars in a program in one time.but some of the buttons in dialogbar2 are still work. only a part of them are disabled ! why ?
can anybody tell me why? thanks in advance!
of if u have some code of using >=2 dialogbars in a program,
can u email me ?
eMial: litterjosser@hotmail.com
nickong
let's talk about code or some funny video
|
|
|
|
|
You have replaced the creation parameters of the bars - perhaps you have the same ids for the two of them?
|
|
|
|
|
Where and how to retrieve the infomation?
Thanks
DJ
|
|
|
|
|
Hi..
i've started using the stl and i am really amazed.. i really like the library.. the most important part for me are the sorting algorithms and stuff like that..
the problem i don't get started seems pretty simple:
i would like to write a functor that takes a second parameter.. and the problem ist that this paramter should be sthing like a const char*..
e.g. i want to copy all the members, where one member var has got a given value.. and this value is a const char* (or a std::string.. no cstrings please)..
could anyone help me?
// sthing like this.. but i would like to compare strings..)
find_if(L.begin(), L.end(), bind2nd(greater<int>(), 0));
thanks in advance
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
You'd do it the same way for strings:
list<string> L;
...
find_if(L.begin(), L.end(), bind2nd(greater<string>(), "hello dude")); Here the comparisons are lexicographical.
That's the great thing about STL: genericity!!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
well.. thank you for this.. but my real problem is as follows..
i mostly use containers of classes.. and so i am writing functions to compare them (i hardly ever use stuff like greater)
and how do i achieve this..
my fun's look mostly like:
bool rmore (const Class* &l, const Class* &r)
{
return (l->x > r->x);
}
i wanted to write sthing like
bool rlikestring (const Class* &c, string s)
{
return (c_membervar = s);
}
does this work this way? (it would be pretty cool for algorithms like remove_if)
thanks for your answer
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
sorry.. it should be
bool rlikestring (const Class* &c, string s)
{
return (c.c_membervar == s);
}
but since i am using const, the compiler would've announced it anways
bernhard
Sometimes I think the surest sign for intelligent life elsewhere in
the universe is that none of them ever tried to contact us.
|
|
|
|
|
Well, if I've understood your need, you must write a functor (sometimes called function object) to plug into find_if and similar arguments. It'd go like this:
class rlike
{
public:
rlike(const string& s):s(s){}
bool operator(const Class* &c){return c.membervar==s;}
private:
const string& s;
} Now you can use this functor as follows:
find_if(L.begin(),L.end(),rlike("hello dude")); Look for function objects on the net for further info on this kind of constructs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I want to know details about writing an import for .DXF files
for a CAD software used in the Laser Construction business. I
have the file formats of the .DXF file but not the CAD software.
I think I need that format. Please be kind to give information
about how to tackle this problem. What other information do
I really need? This has to be done in C++/VC++.
|
|
|
|
|
Let me see if I understand what you're asking for: You want details of the file format for some CAD software, but you don't tell us which software?
I think you'll find more help at wwww.psychic.com.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Not knowing the CAD software envolved, you may find a reference to the file format at:
http://www.wotsit.org/
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
|
|
|
|
|
Hi !
I'm about to write a little app which will be a RPN Calculator, in order to learn a little bit of C++ and MFCs.
The calculator, as all RPN Calc, will have a stack, and at each position of the stack could be a value. The type of this value could be an integer, a float, or anything I might think of (complex number,...).
I thought that I should have an abstract class (CValue), and derive from this class many specific classes for each possible type. Thus, the stack will just store CValue objects, but, when displaying them, the appropriate method will be called. (I hope a make myself clear !!!)
My question now is : if I want to add two values, but, for example, one is of type CFloat and the other one is CInteger (but both are derived from CValue), how can I do it ? How can I make sure that in this example, the CInteger will be converted to a CFloat, and the result will be a CFloat ? Same problem would occur when, for example, multiplying a CComplex with a CInteger ? How can I make it work, in a good object-oriented way ?
Any help or hint will ne greatly appreciated !
Thanks !
Jerome
|
|
|
|