|
install Bounds Checker
never say die
|
|
|
|
|
Hi all,
could any one help me with an STL problem? the code below throws an assertion error [_SCL_SECURE_VALIDATE(this->_Mycont != NULL); from vector.h, line 117] when executing line #5 only after executing line #4. Line #5 works fine as long as the 'if' block is not entered. I am using MSVC 2005 and did not have this problem with the previous version. Is there any change to the way STLs are handled now? Thx everyone,
Ralf.
1 ivFKey = szvCopy.begin();
2 while (ivFKey != szvCopy.end()) {
3 if (*ivFKey == szFKey) //delete all equal; what's left are 0-catches
4 szvCopy.erase(ivFKey);
5 ++ivFKey;
6 }
ralf.riedel@usm.edu
|
|
|
|
|
|
ivfKey = szvCopy.erase(ivFKey)
|
|
|
|
|
I am coding an application that displays a couple of CRgn objects. Each CRgn is filled using anoher brush. So I need two arrays to store the CRgn and CBrush objects.
I also need to save to a file the arrays so when I open the application again I can continue to work with those objects.
It would like to use CArray because I can use m_rgnArray.Serialize(ar) to save the array to a file...
But my program doesn`t work as expected and I get a lot of "assertion failed" messages.
This is how I declared the variables:
<br />
CArray <CRgn, CRgn> m_rgnArray;<br />
CArray <CBrush, CBrush> m_brushArray;
Is this the way I should use CArray with CBrush and CRgn? Is it even possible to use CArray with CBrush and CRgn?
|
|
|
|
|
You can't persist GDI objects like that. You'll need to store the coordinates of the regions and attributes of the brushes, and recreate the GDI objects later.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
<i>LRESULT CALLBACK KeybrdHook( int code,WPARAM key, LPARAM lParam)
{
if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==code))(<b>1</b>)
{
...
GetKeyboardState(ks);(<b>2</b>)
...
ToAscii(key,scan,ks,&w,0);(<b>3</b>)
}
...
}</i>
Could someone please put me out of my misery and explain the lines numbered 1..3. It's driving me potty. There's not a lot of useful, simple to understand explanations on the Net. Many thanks.
EvScott
|
|
|
|
|
EvScott wrote: Could someone please put me out of my misery and explain the lines numbered 1..3.
1) The bits in lParam are being ANDed with 0x40000000. If that result is non-zero and code equals HC_ACTION , the next two statements are executed.
2) The function GetKeyboardState() is being called. When finished, ks is a 256-byte array that will receive the status data for each virtual key.
3) The function ToAscii() is being called. This will translate the specified virtual-key code and keyboard state to the corresponding character or characters.
EvScott wrote: There's not a lot of useful, simple to understand explanations on the Net.
Actually, quite the opposite is true.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
void foo1()
{
foo2();
}
void foo2()
{
foo3();
}
void foo3()
{
STACKFRAME64 frame;
DWORD_PTR programcounter;
programcounter = getprogramcounter();
memset(&frame, 0x0, sizeof(frame));
frame.AddrPC.Offset = programcounter;
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrFrame.Offset = framepointer;
frame.AddrFrame.Mode = AddrModeFlat;
StackWalk64(, , , &frame, , NULL, , , NULL);
}
DWORD_PTR getprogramcounter()
{
DWORD_PTR programcounter;
__asm mov AXREG, [BPREG + SIZEOFPTR]
__asm mov [programcounter], AXREG
return programcounter;
}
My assumption about the above code snippet is that foo3 obtain the address of "getprogramcounter()(program counter?)" by calling getprogramcounter(), and it is
from there the foo3 begin to trace back. So in this case getprogramcounter()->foo3()-2()->1()? But What's the relation between foo3()'s getprogramcounter()'s address and its frame pointer, as the "frame.AddrPC.Offset" and "frame.AddrFrame.Offset" indicate.Doesn't the frame pointer alone enough to get its caller's stack frame? why use program counter? How the StackWalk64 deal with them. What exactly happened?
|
|
|
|
|
Having moved back to Visual Studio 2005, it is now bombarding me with warnings about ISO C++ deprecation of certain functions (such as strdup and stricmp). Most of these warnings disappear when I tell it to mind it's own business with _CRT_SECURE_NO_DEPRECATE. However, is it advisable to actually do what Microsoft say and switch everything over to the new versions of the functions?
|
|
|
|
|
Yes the annoying security warnings
There are many reasons to not use the new functions, even if MS recommends:
- your code gets much more complicated
- no cross-compiling with other compilers/operating systems possible
- every open-source lib you use will bring again these warnings
It is also widely not understood that the wrong functions were blamed by
MS. Most of them are not unsafe and never were. But they depend on correct
usage, so you as the programmer are in charge to not give them garbage.
So, my advice is to use the old functions, and check (if you must use plain C)
every buffer for long enough size, esp. if you get data from user input.
Hans
|
|
|
|
|
Thankyou, Hans. I was thinking something along the same lines, although I never thought of the cross-compatibility issue. Best to check.
HWM
|
|
|
|
|
hi,
I actually have a very simple application,I need to retrieve 2 record from my database.Everytime I click a button then records should be displayed sequentially into my edit boxes.
So,for that I used the code while(!objrs.ISEOF()) and objrs.movenext() where objrs is the recordset object,I can get only one record.
so,pls solve my problem.
bye
swapna_signsin
|
|
|
|
|
|
swapna_signsin wrote: So,for that I used the code while(!objrs.ISEOF())...
Why are you using a while loop when you are only interested in two rows? That would not be very intuitive to someone having to read through the code.
swapna_signsin wrote: ...I can get only one record.
Have you called objrs.MoveNext() a second time to advance to the next row?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
i use ShellExecuteEx to open many other 3rd programme, then i use EnumWindows to get the main window by hProcess returned by shellexecuteex. i found that some programmes, such as notepad.exe, calc.exe, cmd.exe, work correctly. but it couldn't get the correct window of some programmes like word.exe.
|
|
|
|
|
ask yourself, what is the diffrenece between running notepad.exe and winword.exe?
one answer could be that notepad opens immediately and winword first opens a splash screen,
then initialize and only then display the main frame window....
the only way to overcome this is the hook into the creation of the process, and then find out who is the main window and use it.....
hope this helps
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I want to create MFC Application to run console application
Example,when I click a button,it will run a specified console application to open another file.
Like the run command,EX : ConsoleApp Text.txt
Please help me!
|
|
|
|
|
I think you can use CreateProcess function with parameters that show you can use Console type
Agh
|
|
|
|
|
use ShellExecute or ShellexecuteEx
|
|
|
|
|
See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hello
I want to Create a modaless dialog that user can't move it
how can i do it?
thanks.
Agh
|
|
|
|
|
when you drag the dialog a message is called i.e : SendMessage(WM_NCLBUTTONDOWN, HTCAPTION)
just override this message not to do its defaults...
hope this helps
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Add a CRect member to your dialog class and handle the WM_MOVE and WM_MOVING messages. In the WM_MOVE message handler call GetWindowRect() to get the position of the dialog, save it in the CRect member. In the WM_MOVING handler, set the values of the supplied CRect pointer to those in the saved CRect.
void CMyDialog::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
GetWindowRect(m_Rect);
}
void CMyDialog::OnMoving(UINT fwSide, LPRECT pRect)
{
*pRect = m_Rect;
}
The method given above will only work if the user tries to move the dialog with the mouse, it will break when the user uses the Move command in the context menu.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|