|
Hello All,
I have created a DLL that has an export which calls CreateDialog to make a modeless DLL.
CreateDialog(hDLL, MAKEINTRESOURCE(IDD_DIALOG1), mWnd, (DLGPROC)DlgCallBack);
When called, the dialog pops up and everything seems to go right... but locks-up as soon as i click or drag mouse into the dialog. My guess is that something might be going wrong with the way I handle messages or something weird caused by using a dll that I am not aware of, but am not sure since i am new to windows programming. Here is the code in my callback
<br />
switch(uMsg)<br />
{<br />
case WM_COMMAND:<br />
<br />
switch(wParam){<br />
case IDOK:<br />
return TRUE;<br />
}<br />
break;<br />
<br />
case WM_DESTROY:<br />
PostQuitMessage(0);<br />
return true;<br />
<br />
case WM_CLOSE:<br />
DestroyWindow(hwnd);<br />
return TRUE;<br />
<br />
}<br />
<br />
return FALSE;<br />
|
|
|
|
|
KnaveR wrote:
which calls CreateDialog to make a modeless DLL.
Did you mean modeless dialog?
KnaveR wrote:
but locks-up as soon as i click or drag mouse into the dialog.
Could you explain a bit on what you mean by that.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
KnaveR wrote:
return FALSE;
Instead of above call DefDlgProc
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Thnx to both of you.... Sorry for the late reply
Sorry for not properly specifying, but by locking up i ment the infamous "<the app="" calling="" my="" dll=""> has encountered a problem and needs to close" was poping up. For further clarification on what causes this lock up, this occurs anytime I click on the window of the app (mIRC) that calls my dll or move the mouse into my dialog's window. Anyways, after using DefDlgProc, this problem goes away, but the calling app (mIRC) immediately terminates without notice. Any ideas?
|
|
|
|
|
It's been about 11 years since I had to endure writing code without MFC (or more recently, ATL). However, that's where I am. I'm writing a system for a Windows CE 3.0 device and need to declare an array or map of structs within another class. How would I do this in C?
Basically, I have a struct for JobCode.
struct JobCode
{
char* m_number;
char* m_name;
};
And I need to have an array of these in my parent class without hard coding the upper bound.
Cheers,
Tom Archer - Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|
|
Do you have STL available? If so just use vector or map.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
How can he have STL access in C ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Assuming you're using C, and not C++, you need a JobCode*, and you need to use malloc and free, which means you'll be in trouble if you want to grow your array without losing it. You'd need to memcpy the old one into the new space.
Of course, if it's C++, then you need what you should always use, even in ATL/MFC - the STL.
The other solution is to write your own linked list, but I'm not sure how totally ugly that would be, given that it cannot be in a class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Assuming you're using C, and not C++, you need a JobCode*, and you need to use malloc and free, which means you'll be in trouble if you want to grow your array without losing it.
How about realloc or is that not available in C?
|
|
|
|
|
Jack Squirrel Jr. wrote:
How about realloc or is that not available in C?
This is the epitome of a bad function. realloc() has been dubbed the one-function memory manager. If the new size of the block is smaller than the old size, realloc() releases the unwanted memory at the tail end of the block. If the new size is larger than the old size, the expanded block may be allocated at a new address and the contents of the original block copied to the new location. A pointer to the expanded block is returned, and the extended part of the block is left uninitialized. If you attempt to expand a block and realloc() cannot satisfy the request, NULL is returned. If pv is NULL , then realloc() behaves as though you called malloc() and returns a pointer to a newly allocated block, or NULL . If the new size is 0 and pv is not NULL , then realloc() behaves as though you called free(pv) and NULL is returned. If pv is NULL and size is 0, the result is undefined. In summary, realloc() is a prime example of implementation overkill!
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello,
As Christian mentioned, you can write your own linked list. Basically you can write a set of functions for traversing your set of structures. A basic idea of this:
struct JobCodeNode
{
JobCodeNode* pNext;
JobCodeNode* pPrev;
JobCode* pNode;
};
struct LinkedList
{
void* pStartNode;
void* pCurrentNode;
};
LinkedList InitLList(void* pStart)
{
LinkedList LList;
LList->pStartNode = pStart;
LList->pCurrentNode = pStart;
((int*)pStart) = NULL;
((int*)(pStart + 4)) = NULL;
return LList;
}
This is just a basic idea and it can be extended beyond peoples imagination...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Jeez does that bring back memories from 1993! I was hoping that I was forgetting something, but now I distinctly remember writing this code everyplace I worked from 84-93 (before I discovered mfc and collections). Thanks Bob
|
|
|
|
|
You forgot!
Back when I used to write strictly C code, I would create a general purpose
modeule to hadle things like this.
#define LISTHANDLE (void*);
LISTHANDLE List_Create(size_t record_size);
size_t List_Size(LISTHANDLE hList);
int List_Append(LISTHANDLE hList, void* pRecord);
int List_ReadNext(LISTHANDLE hList, void* pRecord);
int List_Insert(LISTHANDLE hList, void* pRecord);
int List_Sort(int (*callback)(void*,void*));
#ifndef BYTE
#define BYTE unsigned char
#endif
typedef struct st_NodeHeader
{
struct st_NodeHeader* pNext;
} NODE_HEADER;
typedef struct st_Header
{
size_t nRecSize;
NODE_HEADER* pHead;
NODE_HEADER* pTail;
NODE_HEADER* pCurrent;
} HEADER;
LISTHANDLE List_Create(size_t record_size)
{
HEADER* pHeader = (HEADER*)malloc(sizeof(HEADER));
if( pHeader )
{
memset(pHeader,0,sizeof(HEADER);
pHeader->nRecSize = record_size;
}
return(pHeader);
};
int List_Insert(LISTHANDLE hList, void* pRecord)
{
if( hList && pRecord )
{
HEADER* pHeader = (HEADER*)hList;
size_t nNodeSize = sizeof(NODE_HEADER) + pHeader->nRecSize;
NODE_HEADER* pNode = (NODE_HEADER*)malloc(nNodeSize);
if( pNode )
{
BYTE* pRec = ((BYTE*)pNode) + sizeof(NODE_HEADER);
pNode->pNext = (NODE_HEADER*)0;
memcpy(pRec,pRecord,pHeader->nRecSize);
return(1);
}
}
return(0);
}
int List_ReadNext(LISTHANDLE hList, void* pRecord)
{
if( hList && pRecord )
{
HEADER* pHeader = (HEADER*)hList;
if( pHeader->pCurrent )
{
BYTE* pRec = ((BYTE*)pNode) + sizeof(NODE_HEADER);
memcpy(pRecord,pRec,pHeader->nRecSize);
pHeader->pCurrent = pHeader->pCurrent->pNext;
return(1);
}
}
return(0);
}
Well you get the idea. Once it is written, you don't have to worry about how
it works anymore. You can expand it to include file I/O for saving to disk,
and you can change how it works interanly, without having to modify the code
that uses it.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
This brings back memories of years of writing OS/2 C code. I definitely never thought I'd be doing this coding again. Thanks John!
|
|
|
|
|
You're welcome
Tom Archer wrote:
Jeez does that bring back memories from 1993!
I had to write such a module in a class 2 years ago and we were forced to do it without any other libraries. My memories might not go back to 1993, but I sure am glad that they are memories.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
My application uses a tray icon (Shell_NotifyIcon) and I need to access the data of my icon displayed.
Does anyone know what a HICON points to and how to manipulate the icon data, or simply after loading an icon yourself, using that in the tasktray or converting it to a HANDLE windows can use?
thanks
|
|
|
|
|
c. s. wrote:
I need to access the data of my icon displayed
What data is this ?
an HICON is a simple handle on your icon, a sort of identifier given by windows which you get after calling one of the multiple CreateIcon...() functions. This handle can then be passed as a parameter for functions such as DrawIcon to actually draw your icon somewhere in your device context.
Search code project (Using the search utility above) with :
tray icon
and you will get a lot of example about how to handle tray icons.
~RaGE();
|
|
|
|
|
thanks, but that isn't my problem. It will probably helpful if I explain what I want to do. I have an animated icon 12 frames long, I also want it to change color depending on what the application is doing, however I don't want to end up making 76 different icons.
I need to access the pixel data so I can overlay a color with 3dnow and mmx, so I need access to the actual memory or load the icon myself and if possible, set the data up the same way the data is set up that a HANDLE points to, and point my HICON at it.
|
|
|
|
|
i want an algorithm for computing the vector that coming out from the rotation of another a vector given that we have the angle of rotation
please coz i eed it in a project in c++
|
|
|
|
|
Sounds like a simple trig problem to me. Sounds like homework, too.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
You don't seem to learn that when you don't ask specific questions about problems in your code, that almost nobody is willing to help you... A good start would be to just grab your textbook and try to implement to algorithm destcribed there.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
NOOO
DONT MISSUNDERSTAND ME!!!!!
i dont want anyone to write the code for me i want only the law of computing this
THE LAWWWWWWWW
ONLY THAT!!!!
thats what i mean by an algorithm i dont mean the code please dont misunderstand me
thats a question about mathematics
how can i rotate a vector with a given angle of rotation?????????????
|
|
|
|
|
So it's only the theory that you are after? In one of your posts you said that you went through google, yahoo and more to find a solution. If that's true, I wonder why you didn't find this[^]. The answer was on the first page of a google search with the keywords: rotate 3d vector.
You'll find only theory there, but you can implement it very easy. I know it's true, since I already programmed the solution in Java.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
yes i found that but i want to know if the rotation id for only 3d vectors
i mean that this page on google is every thing about rotation
i am sorry i may dont ask specific questions but thats because of my poor english
|
|
|
|