|
What I meant was are you allocation memory to data statically or dynamically.
i.e.
char data[1000000];
or
char* pdata;
pdata = new char[1000000];
delete [] pdata;
If you are running through the debugger you should be able to see what it is that is failing to allocate. If you look at the call stack, what is being called?
Ant.
|
|
|
|
|
It's a malloc call. Trying to allocate 22 bytes..
|
|
|
|
|
If this is a C++ program use new /delete instead.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
When you look at the call stack is it calling the same function over and over again?
I.e. trying to allocate 22bytes over and over again?
Ant.
|
|
|
|
|
You may have corrupted the heap.
Usually this is because you've written to an uninitialized pointer, or written before/beyong the end of an array or object that you've previously allocated on the heap.
|
|
|
|
|
How may I change the default color in my CDialog with all my cildren-windows ( CButtons, CTabCtrl, … )
...and justice for all
APe
|
|
|
|
|
perhaps the is a better way, but i would subclass all objects
and overwrite the wm_ctlcolor method of each object
|
|
|
|
|
OK!! Thanks
Any suggestion how to make my dlg RGB(255,0,0) ?
...and justice for all
APe
|
|
|
|
|
for example:
HBRUSH CCtlcoloDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
CBrush *brush = new CBrush(HS_BDIAGONAL,RGB(200,0,0));
return (HBRUSH)(brush->GetSafeHandle());
}
i would declare and construct the brush outside the OnCtlColor Method
|
|
|
|
|
You're the King and made my Day - Thanks
...and justice for all
APe
|
|
|
|
|
How do I write a function that has a variable number of parameters. Ideally I would like the first parameter to be an integer, and then that number of parameters must be entered.
For example
function(5,1,2,3,4,5)
or
function(3,1,2,3)
Thanks
|
|
|
|
|
for variable no. of arguments use va_arg, look into MSDN for more details
|
|
|
|
|
return_type fonction (...); the '...' is the C style to say that th function can have a variable number of parameters.
if you want fixed parameters, with a variable list below , do this (printf() function for example):
<font style="color:blue;">int</font> printf(<font style="color:blue;">const char</font>*, ...);
To access such parameters, use the macros va_start (), va_arg () and va_end (), plus the va_list type.
TOXCCT >>> GEII power
|
|
|
|
|
In this particular case:
int function( int nParams, ... ); and then use va_list :
int function( int nParams, ... )
{
int argValue;
va_list args;
va_start( args, nParams );
for ( int nParam = 0; nParam < nParams; ++nParam )
{
argValue = va_arg( args, int );
}
}
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is there any wizard to add massege map for toolbar items in the IDE of VS .NET?
There are only menu commands in property view.
|
|
|
|
|
Hi
In my property sheet, i disabled all default property sheet buttons. Now i want to add my own buttons to Property sheet. How to implement this?
Thanks
JP
ALL THINGS ARE POSSIBLE UNTIL THEY ARE PROVED IMPOSSIBLE-AND EVEN THE IMPOSSIBLE MAY ONLY BE SO,AS OF NOW
|
|
|
|
|
There is no easy way - you will have to add it one-be-one, after getting pointer to sheet window itself. I have not used it for a long time, but probably you have to do it from OnInitDialog.
I'm using my own class, which is dialog based (so you use template for it), and handles switches of pages. Here is screenshot of typical complex dialog example, using this approach: http://www.grigsoft.com/ws000.gif[^]. If somebody is interested, I could probably post an article on CP about it - I will just clean up the code a bit.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Is there any meaning in setting baud rate to virtual serial ports ? Do they really work?
|
|
|
|
|
An optional feature of a VDD is the direct dispatch function. Your application can call this function directly instead of through the I/O
instruction trap.
Transmit buffering also may use queues. Queues are not supported directly by Win32, but they are easy to implement using a mutual exclusion object and a
semaphore object.
Overlapped I/O is another point. Under Win32 you must specify overlapped I/O or any file operation will block all others until it completes. For serial communications this includes WaitCommEvent as well as ReadFile and WriteFile. In the VDD this would have prevented any reads or writes while the status monitoring thread was waiting for a comm event.
A CRITICAL_SECTION object is used to control access to the UART state. This allows the status monitoring thread to update the virtual UART state asynchronously. A Mutex object could have been used as with the transmit buffers, but a critical section is more appropriate in this context.
|
|
|
|
|
woah!!! this does not looks like answer to my question..
|
|
|
|
|
Hi
I am new to MFC, i have written function to highlight a perticular line in richeditview class. find the routines below. But i am not able to change the background of a line (presently in black color). i am able to change the text color. I tried with CHARFORMAT2, but its not working.
So plz help me out to solve this problem
void CDbgView::HighlightLine(int GLineNum)
{
int FirstVisibleLineNum = pSCodeView->GetRichEditCtrl( ).GetFirstVisibleLine() + 1;
int LastLine = FirstVisibleLineNum + pSCodeView->GetRichEditCtrl( ).GetLineCount();
int nBegin,nEnd;
nBegin = pSCodeView->GetRichEditCtrl().LineIndex(GLineNum-1);
End = pSCodeView->GetRichEditCtrl().LineLength(nBegin);
// Select the range of charecters.
CHARRANGE cr;
pSCodeView->GetRichEditCtrl().GetSel(cr);
cr.cpMin = nBegin;
cr.cpMax = nBegin + nEnd;
pSCodeView->GetRichEditCtrl().SetSel(cr);
//Change the Bk Color of the line selected
/*CHARFORMAT2 cf;
pSCodeView->GetRichEditCtrl().GetSelectionCharFormat(cf);
cf.cbSize = 84;
CHARFORMAT2* pcf = &cf;
pSCodeView->SendMessage(EM_SETCHARFORMAT,(WPARAM) SCF_ALL,(LPARAM) pcf);
cf.dwMask = CFM_SIZE | CFM_BACKCOLOR ;
cf.dwEffects = CFE_PROTECTED | CFM_COLOR | CFM_BACKCOLOR;
cf.crBackColor = RGB(0,0,255);
pSCodeView->GetRichEditCtrl().SetSelectionCharFormat(cf); */
pSCodeView->UpdateWindow( );
}
Thanks
Irshad
|
|
|
|
|
i do it this way:
void MyClass::SetBold(void)
{ CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD;
DWORD dwSelMask = GetSelectionCharFormat(cf);
if( (cf.dwMask & CFM_BOLD) & (dwSelMask & CFM_BOLD) )
{
cf.dwEffects ^= CFE_BOLD;
}
else
{
cf.dwEffects |= CFE_BOLD;
}
cf.dwMask = CFM_BOLD;
SetSelectionCharFormat(cf);
}
|
|
|
|
|
thanks for reply...but i want to change the background color of hightlighted line...presently it is black...
so i tried to use CHARFORMAT2...but i am not able set the size attribute & i am not able send a massage for CHARFORMAT2
regards,
Irshad
|
|
|
|
|
Hello,
i like to read in a data string from my serial port. The string has the format like:
[123.233, -4.344, 45.678].
I want to readout this string and transfer the three values into float x,y,z variables for further processing.
The code below is a part of my old code which works with only a "1" character input. What i have to change?
char cReceivedChar[1];
cReceivedChar[0] = '\0';
DWORD dwBytesRead;
if (port.Read(cReceivedChar, 1 , overlapped, &dwBytesRead)) // 1 is number of bytes read from port, how to make this variable?
{
CString nx = cReceivedChar[1];
SetDlgItemText(IDC_SHIFT_X,("%c", nx));
}
Thanks, Mark
|
|
|
|
|
why not simply
CString nx ;
while (port.Read(cReceivedChar, 1 , overlapped, &dwBytesRead)) // 1 is number of bytes read from port, how to make this variable?
{
nx += cReceivedChar[1];
}
AfxMessageBox(nx);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|