|
Yes you're right, I was a little bit too 'extreme' in my answer. In fact, it is because I saw people using it to circumvent C++ type safety (to "make life easier"). That was quite scary...
|
|
|
|
|
Cedric Moonen wrote: I saw people using it to circumvent C++ type safety (to "make life easier"). That was quite scary...
I agree with that. I've seen this before too. Specifically people casting pointers to C++ classes to long s and storing it in a VARIANT and passing it through COM interfaces; talk about missing the point of COM.
Steve
|
|
|
|
|
sorry i didnt know it was posted after i tried cancelling it.. anyways do you have some answer to my ques?
harsha
|
|
|
|
|
Look at MSDN for GetKeyState and GetAsyncKeyState . Use these functions with the virtual key codes of "Control key" and the 'A' key while you handle key down event in your application.
Absence is to love what wind is to fire; it extinguishes the small, it enkindles the great - Comte Debussy-Rabutin
|
|
|
|
|
Hi
i want to know in terms of memory allocation what is the diffrence between the debug and execution mode
i have a code that work fine in debug mode and finish successfuly while its faild in execution mode
with the error :
The instruction at "0x...etc" referenced memory at "0x000000002c" .The memory could not be "written"
my code is :
<br />
for(i=0;i<stringLength;i++)<br />
{<br />
<br />
dSegment.segment=(int *)realloc(dSegment.segment,sizeof(int)*(++dSegment.DC));<br />
dSegment.segment[dSegment.DC-1]=string[i];<br />
printf("%d %c\n",i,string[i]);<br />
}
and the declaration of dSegment is
struct <br />
{<br />
unsigned int DC;<br />
int *segment;<br />
}dSegment;
thank in advance
|
|
|
|
|
Ayman Mashal wrote: 0x0000002c
That address tells you that you likely did something off of a NULL pointer, so I would start there.
If the calculation of the memory size used in the call to realloc(...) is broken, and it looks possible because there is no testing/verification visible in the code you provided, realloc(...) can return a NULL value, and the following line would cause an exception in that case.
BTW - the allocation differences between release and debug are many, and some objects (like MFC's CString ) even allocate memory differently in release mode than in debug mode (it allocates exact amounts in debug, but allcoates in blocks in release). The first thing is that under debug mode, memory allocation routines will often pad allocated memory with special bytes allowing you to detect overruns.
Are you sure that you have no memory-related issues in debug mode? You have to run the program to completion to find all of them, not just stop it in the debugger.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
you are right
at some point realloc returns NULL !!!! why ?
the calculation of the memory size is fine i put some print messages in the code and here is the output :
DC: 0
before realloc : 0
after realloc : 323b78
DC: 1
before realloc : 323b78
after realloc : 323b78
DC: 2
before realloc : 323b78
after realloc : 323b78
DC: 3
before realloc : 323b78
after realloc : 323b20
DC: 4
before realloc : 323b20
after realloc : 323b20
DC: 5
before realloc : 323b20
after realloc : 323b20
DC: 6
before realloc : 323b20
after realloc : 323b20
DC: 7
before realloc : 323b20
after realloc : 323b20
DC: 8
before realloc : 323b20
after realloc : 323b20
DC: 9
before realloc : 323b20
after realloc : 323b20
DC: 10
before realloc : 323b20
after realloc : 323b20
DC: 11
before realloc : 323b20
after realloc : 323b20
DC: 12
before realloc : 323b20
after realloc : 323b20
DC: 13
before realloc : 323b20
after realloc : 323b20
DC: 14
before realloc : 323b20
after realloc : 323b20
DC: 15
before realloc : 323b20
after realloc : 323bc0
DC: 16
before realloc : 323bc0
after realloc : 323bc0
DC: 17
before realloc : 323bc0
after realloc : 323bc0
DC: 18
before realloc : 323bc0
after realloc : 323bc0
DC: 19
before realloc : 323bc0
<big>after realloc : 0</big>
note that if i decrease my string length its work fine !!
is there any place in the project setting the sets the allowed space for the programme ?
thanks
|
|
|
|
|
Ayman Mashal wrote: at some point realloc returns NULL !!!! why ?
Gotta love realloc()!
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
|
Three same messages
|
|
|
|
|
ok it was by mistake.... you have some answer?
harsha
|
|
|
|
|
|
ok question is.. i hav a list control in my dialog and i should have provision to select all the entries in it on Ctrl+A down like it happens in standard windows dialogs
harsha
|
|
|
|
|
When you click on the listctrl(Ctrl+A) it selects all items what problem?
|
|
|
|
|
no its not selecting automatically like that.....
harsha
|
|
|
|
|
Hi harsh,
When I wa clicking on my program (Ctrl+A) all items are selected,and then when I want to read them use of GetFirstSelectedItemPosition /GetNextSelectedItem
I dont have my code now,but use of this code SetItemState(Index, LVIS_SELECTED, LVIS_FOCUSED); and now what happens?And reply to me it work or no,please;)
|
|
|
|
|
how to change the background color for tab (to be same as screen)
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
|
i need to change the tab bar color and its fonts
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Hi,
on my view i have a Textbox, a Combobox and a Grid (from BCG )
If the focus is on the textbox and the user presses the PageUp Key, the focus
should be setted on the Grid
I catch the Key_Press in the PreTranslateMessage-Handler and verify if the
message is WM_KEYDOWN and the wParam is VK_PRIOR
Then a "Grid->PostMessage(WM_SETFOCUS);" should set the focus on the Grid
and after this i return directly TRUE, so that the Message is not be redirected but
"destroyed"
Does the focus re-enter on the textbox because it was a Key-Stroke?
Big thanks
|
|
|
|
|
I am never one to suggest "new GUI behavior", like having Page-Up cause a focus change( !), but have you tried using Grid->SetFocus() ? Using PostMessage(...) causes the set focus message to get queued, but other messages may execute before it affecting the focus.
You also may need to eat the WM_KEYUP message that may get sent to the grid, JIC the grid processes that message.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Grid->SetFocus() resolves the problem.
For me, it's logical that a SetFocus()/SendMessage(WM_SETFOCUS) is too early
"...causes the set focus message to get queued, but other messages may execute before it affecting the focus." --> so the keyUp is affected and after this, the grid becomes the focus.
Big thanks to you
Yeah it's strange to change the focus with PageUp, but i re-code an existing DOS-program, which
should keep all keystrokes, because all users are used to use for example this kind of behavior.
The Tab-Key should switch into the different textboxes and a PageUp siwtches to another "section" of the Window
|
|
|
|
|
Hi
how can i open and read registry keys and values from the registry editor.
if any one has source code for this than please tell me .
or any type of help will make my application to move to other module
|
|
|
|
|
Look into MSDN for keyword CRegKey
I am not ashamed to confess that I am ignorant of what I do not know.
- Marcus Tullius Cicero
|
|
|
|