|
What a shame that I didn't had the chance to experiance those good old days...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I used Oscilloscope control in win32 and i always get an error while graph was plotting data
"Unhandled exception in sm85032.exe (UOPORT.DLL): 0xC0000005: Access Violation."
as i debug into the code the source of the problem was an error in freeing a "POINT" type
pointer variable in the oscilloscope header.
Would there be any problem if i use WTL code in win32?
or is there anything i should set before accessing WTL code.
Any hints on this one.
Thanks!
|
|
|
|
|
Please show the code for freeing the pointer.
Some functions throw exceptions when freeing memory which was never allocated.
And there are no problems when using WTL in Win32 as far as I know.
this is this.
|
|
|
|
|
Here is the code from the header file of the Oscilloscope control
http://www.codeproject.com/wtl/WTL_Oscilloscope.asp[^]
void SetPoints(size_t time, double* values, size_t count)<br />
{<br />
m_time = time;<br />
m_values = values;<br />
m_pointsCnt = count;<br />
<br />
if (m_points) <br />
delete [] m_points;
m_points = new POINT[m_pointsCnt];<br />
<br />
_UpdateYRange();<br />
_Recalc();<br />
}<br />
One thing is that these line do not encounter error not until the 18th time it was accessed so im wondering why?
Any suggestions? Thanks!
|
|
|
|
|
Respected all
Regards!
I am David from Denmark ,, have a problem.
" How to draw the Sin() or Cos() function from 10 to 200 values against time on graph,b/c I have Scalling problem to draw .
Plz guide me.
Best wishes
David
david
|
|
|
|
|
If you were asking for how to draw them, maybe following charting controls may help you:
Charting controls[^]
If you were asking for how to get the data, that's a math problem, please post again with more details.
Hope this helps
~RaGE();
|
|
|
|
|
Hi all,
Anyone could show me the code to open an excel file (*.xls)in VC++?
Thanks a lot in advance.
Grenouille
|
|
|
|
|
|
See the MSDN article Q178749.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi!
I've developed a dialog based application using MFC. In the application I've created an edit box dynamically. On the edit box I do some validation and displays messagebox and sets the focus on the edit box using SetFocus().
The problem I'm facing is, after the validation though the focus goes back to the edit box but the cursor does not blinks as it do initially which can be confusing to the end user.
Kindly help on this!!
Thanks.
|
|
|
|
|
topagarwal wrote:
ocus goes back to the edit box but the cursor does not blinks
Try calling setCursor when you get focus on the edit control.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
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!
|
|
|
|