|
hi there !
i got a crucial problem with my singleton class. maybe there's anybody who could help me out
i implemented a singleton framework as a static lib that handles callbacks, triggers methods etc.. next to this lib, i got several dlls that access this lib.
the problem basically is that every dll allocates its own memory and includes a copy of the lib there. so, from outside (let's say, the testing app), there's not one framework, but several according to the amount of dlls that load the framework.
as there must be only one framework, i'm looking for kind of a workaround to get rid of this "feature".
i've already tried to build the singleton as a dll which then just would be linked to the other dlls, but that didn't show any positive effect either.
so in other words, is there any memory segment (which would be the heap of the current context/process) that is used by all libraries (be it static or dynamic) that i could store at least the singleton pointer in ?
a really quick solution would be to instantiate this pointer at the testing app or create a shared memory object, but these kinds of solution don't satisfy me at all.
as i'm in an absolute rush, pls come back to me as soon as possible. thank you all very much for any hint or opinion.
best regards,
j
|
|
|
|
|
Singleton 'pointer' ? This does not make any sense to me. You can't readily create a pointer to some memory segment that is the same address among all processes.
The address returned by any regular 'malloc' or 'new' calls is not guaranteed to be at the same address in all processes anyway. You can try to FORCE it using some combination of VirtualAlloc and memory mapped file calls, but you always, and I mean ALWAYS, run the risk that some DLL will load at that address anyway. So then by the time your app is running its main loop, you will not be able to allocoate memory at that address anyway.
If you want something 'shared' by all processes, your best bet is to create a memory mapped file and map to it from each process. Put your 'pointer independent' code in that shared memory.
If you want a fixed-size chunk of memory that is shared by all processes that is 'owned' by a DLL, then you can put some variables or data structures into a shared data segment.
|
|
|
|
|
In my application I have a picture box in which I display a bitmap, the bitmap has a number of points on it which I need to join up with an arrow to show the direction of the join (I know where the points are and also the direction).
Does anyone know an easy way to calculate which pixels I need to colour to create this arrowed line.
TIA
|
|
|
|
|
mcsherry wrote:
...to create this arrowed line.
Is LineTo() what you are looking for?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
LineTo() is this using a device context? if so I can't use that (I don't think so anyway ) as I need to actual draw it on the bitmap before saving it all to a file.
cheers,
|
|
|
|
|
Understood, but I think you can still use LineTo() to modify the bitmap, and then display the final result. You need to select the bitmap into a compatible DC, add to it using LineTo() , and then draw it using BitBlt() . Something like:
CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);
CBitmap *pBitmap = dcCompatible.SelectObject(pointer_to_CBitmap_object);
dcCompatible.LineTo(...);
pDC->BitBlt(0, 0, width_of_bmp, height_of_bmp, &dcCompatible, 0, 0, SRCCOPY);
dcCompatible.SelectObject(pBitmap);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thanks, I'll give that a go.
Andy,
|
|
|
|
|
Where can i find source code?
|
|
|
|
|
Rassul Yunussov wrote:
Where can i find source code?
Google shows a few implementations. But nothing really drop-in ready.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hey!
how do I make a multi-column popup menu using e.g. cmenu' popup features ?
Thanks !
- Karmafx
|
|
|
|
|
figured it out...using MF_MENUBARBREAK..doh
-Karmafx
|
|
|
|
|
Hello ,
I have one doubt in MFC.I create one application.In this application i draw one rectangle in the client area.The rectangle contains the Eight handles (MASK) using GetHandleMask().I draw another rectangle same as the first one.Now i drag the second rectangle and fixed in the part of first rectangle.Now click the first rectangle,the handles not shown in the intersected area.How it will show?I need only handle are shown,not line.
Sunsen
|
|
|
|
|
Hello!
I've a problem, i can't show a CStatic in my Dialog!
this is my code:
On OnInitDialog()
<br />
CBitmap m_bmp;<br />
BOOL res = m_bmp.LoadBitmap(IDR_BMP_NEW2);<br />
if (res) MessageBox("Image ok")
<br />
CStatic myStatic;<br />
<br />
myStatic.Create(_T("my static"), <br />
WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE|WS_BORDER, CRect(10,10,150,50), this);<br />
myStatic.SetBitmap(HBITMAP(m_bmp));<br />
when i launch my app, there is nothing on Dialog
plz, help me! thanks
hzocm
|
|
|
|
|
|
I think the problem is due to the fact that your CStatic is a local variable... so it gets destructed at the end of OnInitDialog... declare as a member of the class and you will have more luck!
|
|
|
|
|
thanks very much!
it's ok, i must declare CBitmap and CStatic like a varible of class.
thanks!
|
|
|
|
|
|
BadJerry wrote:
de rien!
c'est rare des gens polis de nos jours...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Merci!
Moi etre bon petit gars!
Tres impressionne par le nombre de gens que tu peux aider . Tu arrives a travailler aussi ou cp est une occupation a plein temps?
|
|
|
|
|
BadJerry wrote:
Tu arrives a travailler aussi ou cp est une occupation a plein temps?
|
|
|
|
|
disons que je suis en formation (depuis 2 semaines), et que le programme pour le moment est suffisament facile pour que je puisse me permettre d'aider qques codeurs perdus...
BadJerry wrote:
Tres impressionne par le nombre de gens que tu peux aider
merci, je prends ca pour un compliment. Par contre, un peu amer contre la personne qui s'amuse à voter tous mes posts à 1 de temps en temps sans meme lire leur contenu ; mais c'est une autre histoire
ps: sorry for those that didn't understand that conversation...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Definetely a compliment... You and hatsAlok are doing a terrific job!
Yes I hate the voting system as it is... if you vote 1, you should have to justify it (or at least lose your anonymity)...
|
|
|
|
|
should i justify why i vote 5 also ?! :->
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
can we send mail thourgh program or code in vc without the local smtp server on that machine
ddd
|
|
|
|
|
Yes, since SMTP is a *network* protocol. Providing there's an accessible SMTP server that the machine can connect to, there's no real difference (firewall/security measures aside) from communicating with a server on the same machine or a remote one.
Steve S
Developer for hire!
|
|
|
|