|
With extension DLLs you should have no problems with resources - .exe and all extensions will have their resources chained; all MFC functions dealing with resources will search through all MFC-based modules.
To get access to resource #defines, include resource.h from .exe project in .dll projects.
Anonymous wrote:
I have to create some DLLs which will be loaded dynamically at runtime by the SDI application (at some stage only a DLL is loaded).
?? You mean that there will be no .exe?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
The .exe will be that container application...but when the app has to load a new dll, it will unload first any other dll loaded before.
Thanks
|
|
|
|
|
I have done something very similiar recently...
I've used a CTabView in my executable that shows dialogs loaded from extension DLL's.
I pass a controlling class to the DLL, and the dll calls a function to add a tab.
control->AddTab(myDlg->GetSafeHWND()).. the only thing that caused me some headache was the AFX_MANAGE_STATE(AfxGetStaticModuleState()); I had to insert in the correct places...
If you need any help, email me at ashran@god.hackersquest.org, but before you email me, remember there is no god!
/wave
|
|
|
|
|
Hi
I'm going round in circles and could do with some help. I have an application that draws a whole lot of information to a window via a subclass of CView. Now I need to save a copy of what is in the window in a particular format. I thought if I created a new view using a memory device context I could get the system to draw itself to this new view and then pull the required data out of memory but I can't seem to find a way to set up a memory device context with the format that I want (16bit gray scale would be ideal - i'll settle for 8bit if I have to).
CreateDC wants me to specify a lot of stuff about drivers .
CreateCompatibleDC gives me something according to the current system device, but trying to select a bitmap of a particular format into this fails because the two are not compatible. CreateCompatibleBitmap seems to give me a monochrome bitmap.
I'm sure it is very easily done but my brain has gone fuzzy.
|
|
|
|
|
CreateDIBSection accepts BITMAPINFO on input, this allows you to specify the color depth.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Seems a good idea. Now I have the following..
---------------------------------------------------------------------------
CDC dcMem;
dcMem.CreateCompatibleDC(NULL); // Needed otherwise handle is uninitialised
// Set up all the BITMAPINFO data
char pDIBHdr[sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)];
BITMAPINFOHEADER *pBitmapInfoHdr;
RGBQUAD *pRGB;
pBitmapInfoHdr = (BITMAPINFOHEADER *)pDIBHdr;
// Setup the header information for the device independent bitmap which
// is going to be used
pBitmapInfoHdr->biSize = sizeof(BITMAPINFOHEADER);
pBitmapInfoHdr->biWidth = 256;
pBitmapInfoHdr->biHeight = 256;
pBitmapInfoHdr->biPlanes = 1;
pBitmapInfoHdr->biBitCount = 8;
pBitmapInfoHdr->biCompression = 0;
pBitmapInfoHdr->biSizeImage = 0;
pBitmapInfoHdr->biClrUsed = 0;
pRGB = (RGBQUAD *)(pDIBHdr + pBitmapInfoHdr->biSize);
for(int ii=0;ii<256;ii++){
pRGB[ii].rgbRed = ii;
pRGB[ii].rgbGreen = ii;
pRGB[ii].rgbBlue = ii;
}
void* pTmpMem;
CreateDIBSection(dcMem.m_hDC,(BITMAPINFO *)pDIBHdr,DIB_RGB_COLORS,&pTmpMem,NULL,0);
dcMem.Rectangle(CRect(0,0,100,100));
pData = (short *)pTmpMem;
// Now use pData to access the actual data out of the bitmap
--------------------------------------------------------------
The output I now get doesn't reflect the Rectangle draw that I performed.
Should it ? Although I have created this DIB is it selected into the DC as the memory surface onto which the draw functions will be occurring. If not how does one achieve that, so that the draw functions accessed via the DC will write into this DIB.
Thanks
Andrew
|
|
|
|
|
You've forget to select your DIBSection into dcMem. The first paremeter you're passing to CreateDIBSection is used only to initialize DC palette when you pass DIB_PAL_COLORS as 3rd param.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi All !
I have read that the C# threading classes in .NET causes an
exception to be thrown in a thread if that thread is being ended
by another thread.
Any idea's on how to implement this with VC 6.0 ? This could provide an
excellent alternative to polling for stop flags.
Kind regards,
Alwin
|
|
|
|
|
March'96 issue of MSJ has the answer, unfortunately, it'll work on NT/2K/XP only. Check the 'QA Win32' by Jeffrey Richter. The article may be in MSDN installed on your HD, if it's not there, check the msdn.microsoft.com.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
this is just an idea.
U heard of 'atexit' . use it to register a fn,
put the handle to the current thread in a global
variable and inside the fn so some thing like this.
HANDLE hOriginalThread ;
viod ThreadFn()
{
atexit(fn) ;
..
..
}
void fn
{
if( GetCurrentThread()!= hOriginalThread)
AfxThrowMemoryException() ;
}
U can work out the way out of global variable .
One last thing, u means of throwning exception is alright
but where will it be caught ?
|
|
|
|
|
There's a number of reasons why this cannot be achieved in general, the most important one being that the compiler often assumes portions of code throw no expceptions and takes advantage of this for optimization. Also, if there's floating point arithmetic involved the issue becomes even more tricky, as these operations are usually performed by a separate coprocessor (you can think of them as performed by a microthread), which yields the approach of "everything can throw an exception" a hard one to handle. Other, less important difficulties are those posed by the hard time programmers will have if they must assume everything can throw --think of how you'd prevent memory leaks in such situations.
First releases of Java included this termination-by-exception approach, but later on they deprecated it for the reasons mentioned.
Of course, these problems can be tackled in C# as this language runs in a strongly managed environment. The downside is resulting poor performance.
That said, you can have a thread inspect for termination conditions and throw accordingly upon calling a selected set of DLL functions (even system functions from KERNEL32, USER32, etc.) Check PJ Naugter's HookImportFunctionByName v1.0 for details.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
does anyone know how to write this as call by constant reference using pointers?? here is what ive been trying to do:
int CComputer::CheckForMoves(const CBoard& rBoard, int depth)
{
CBoard Board = rBoard; <-- but using pointers instead of reference
}
so i can call it in the main function like this:
CheckForMoves(pBoard,1); where pBoard is a pointer of CBoard
is there a way i can do something like that without getting any syntax errors????
cause i have tried all sorts of stuff like that but the compiler wont allow
me to do so....
anyways, thanx for you help
John
|
|
|
|
|
CheckForMoves( *pBoard,1) ;//main fn
int CCtrlResize::CheckForMoves(const CBoard& rBoard, int depth)
{
const CBoard& Board = rBoard; //Init to a const referece, because thats what it is
return 0 ;
}
|
|
|
|
|
Well, I guess I got it wron then!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
What I know that is not allowed!
You have to use either references or pointers.
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Pointers and references are not the same thing, you can't use both at the same time*. You can either write:
int CComputer::CheckForMoves(const CBoard& rBoard, int depth)
{
const CBoard& Board = rBoard;
const CBoard* p = &rBoard;
} which passes the param as a reference, or:
int CComputer::CheckForMoves(const CBoard* pBoard, int depth)
{
const CBoard* p = pBoard;
const CBoard& refBoard = *pBoard;
} which passes a pointer.
* Note for C++ experts: yes I know you can have a reference to a pointer; I didn't mention that above because it would be unnecessarily confusing.
--Mike--
Best score on the mini-putt game: 27
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
hey thanks everyone for help me. ill try all your suggestions to see it would work. thank you very much again
|
|
|
|
|
Try CheckForMoves(*pBoard,1) .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hey Joaquin... thank you it worked... been think bout this the whole day and i didnt try putting a pointer like CheckForMoves(*pBoard,1).... i think i overlooked that part...
muchas gracias mi amigo por me ayudo...
|
|
|
|
|
Hi, veterans, I'm a student of C.S. I'm going to do a Windows program on drawing with MFC for my class project. Before I get into the real coding, I have to write a development plan to describe how I am going to do the project. I never made one before, and I have no any idea how to write a legitimate one. Please help, with some examples if any. Thanks very much.
|
|
|
|
|
i would like to know how to use the "explorer like interface" that is createble from the appwizard. A sample would be great.
Im not so familiar with the doc/view so please keep it as simpel as possible
Thanks in advance.
/Stefan
|
|
|
|
|
check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I want my dialog to popup with a fade affect , where in my program should i put the AnimateWindow() function ?
thanx
|
|
|
|
|
OnInitDialog()
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Thanx(so simple..)
|
|
|
|