|
Thanks to all that helped but I got it. Only took me 9 hours
For those interested it was a simple index out of bounds. I had two constants defined as the maximum sizes of two arrays I was using and I was looping through one array (and writing to it ) using the wrong max size.
Anyway, thanks again everyone.
James Spibey
I love the word naked, it's brilliant isn't it, 'naked'. When I was a kid I used to write the word naked on a bit of paper hundreds of times and rub my face in it - Jeff, Coupling, BBC2
|
|
|
|
|
Great!
I was justing working on my repost. I was going to tell you to check for...
arValules[10];
for (int i = 0; i <= 10; i++)
...
I used to do this all of the time.
Anyway, glad you solved your problem.
Matt Gullett
|
|
|
|
|
A few things to check.
1. Rogue pointer - You have a pointer that hasn't been properly initialized that is trashing another variable when used.
2. Use of deallocated memory - You deallocate memory, that memory is then allocated to your new object. However, another piece of code is still trying to access the old object thus trashing the data in the new.
3. You are returning a pointer to a stack object.
4. Your object is located on the stack and another buffer (such as a character string) isn't large enough to hold an array of data. Thus when you write this data into the buffer, you trash other objects on the stack. This can also happen with allocated memory.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Thanks for the response. I have actually run the code through boundschecker and it didn't throw up any of the above.
A quick expanation of the code - it's a CWnd derived class which includes a load of CUIElemnt objects which represent GUI objects. When I receive OnMouseDown messages I call PointInRect for each element and if they report that the click was within their bounding rect, I call Clicked() on that element. On the next OnMouseUp messages I scan for the clicked element, perform an action and then call Release() on that element.
This works OK for some elements but on one particular one, I get an access violation when I call Release on the mouse up. This is in addition to some elements returning TRUE to IsClicked when they haven't been Clicked(). I don't understand why I'm getting an access violation - I might expect it when using pointers but I'm not.
class CUIElement
{
public:
BOOL PointInRect(CPoint point);
void Clicked();
void Release();
BOOL IsClicked();
protected:
BOOL m_bClicked;
};
CMyClass
{
public:
... Many Access Functions
Protected:
CUIElement Button1;
CUIElement Button2;
CUIElement Button3;
CUIElement Button4;
};
James Spibey
I love the word naked, it's brilliant isn't it, 'naked'. When I was a kid I used to write the word naked on a bit of paper hundreds of times and rub my face in it - Jeff, Coupling, BBC2
|
|
|
|
|
Hi everyone. I have a dialog with a property sheet, with property pages, which I set up in the code below. The question I have is, how do I set the focus to a text box in the first property page when the dialog and then the property sheet is created afterwards. The idea is what when the dialog pops up, the focus is set to the edit box in the first property page in the property sheet, so the user can begin to enter data immediately, without having tomove the mouse or use the tab key to switch the focus from the OK button on the dialog to the edit box on the first property page.
<br />
CPpgOne* m_ppgOne;
CPpgTwo* m_ppgTwo;<br />
CPpgThree* m_ppgThree;<br />
m_ppsMain.AddPage(m_ppgOne);<br />
m_ppsMain.AddPage(m_ppgTwo);<br />
m_ppsMain.AddPage(m_ppgThree);<br />
<br />
m_ppsMain.Create(this, WS_CHILD | WS_VISIBLE, 0);<br />
m_ppsMain.ModifyStyleEx(0, WS_EX_CONTROLPARENT);<br />
m_ppsMain.ModifyStyle(0, WS_TABSTOP);<br />
CRect rcSheet;<br />
GetDlgItem(IDC_PPS_PROPSHEET)->GetWindowRect(&rcSheet);<br />
ScreenToClient(&rcSheet);<br />
m_ppsMain.SetWindowPos(NULL, rcSheet.left- 7, rcSheet.top - 7, 0, 0,<br />
SWP_NOZORDER | SWP_NOSIZE);<br />
<br />
Every time I try and modify the focus anywhere, it always ends up on the OK button of the dialog the property sheet is on. Anyone have any ideas? I can provide more code if necessary.
|
|
|
|
|
one way to do it is to use the CTRL + D when you are in the resource view and then set the order of your components.
so the first one has to be the edit box in your case and the last one the Ok button.
i hope it helps.
Fred
|
|
|
|
|
Apart from settin gth tab order as suggested by Fred, you can set the control you want to have the focus in the OnInitDialog() function for the dialog by calling SetFocus() on that control. Remeber that you will need to return FALSe to let the CDialog class know that you set the focus to a control.
As your control is in a property page, you will need to get a pointer to that page in the OnInitDialog() and then a pointer to its control before being able to set the focus.
HTH
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
|
|
|
|
|
Anyone know how I can get a list of all local and network printers installed on a PC? I have a program that when it detects a fire, I'd like to print a fire report on every printer possible. Anyone got any ideas please? Thanks
Jeremy Davis
http://www.astad.org
|
|
|
|
|
See EnumPrinters and OpenPrinter.
|
|
|
|
|
Alex Farber wrote:
See EnumPrinters and OpenPrinter.
Thanks! I'll try that.
Jeremy Davis
http://www.astad.org
|
|
|
|
|
sorry to sound like i'm laughing at you ... i'm not but i can't help but imagine the printouts:
"THERE IS A FIRE AND YOU SHOULD RUNNING THAT WAY!!!"
with an arrow pointing at the the nearest fire escape
---
"every year we invent better idiot proof systems and every year they invent better idiots ... and the linux zealots still aren't being sterilized"
|
|
|
|
|
lauren wrote:
sorry to sound like i'm laughing at you ... i'm not but i can't help but imagine the printouts:
"THERE IS A FIRE AND YOU SHOULD RUNNING THAT WAY!!!"
with an arrow pointing at the the nearest fire escape
No problem! Anyway if there's a fire, all the printers and network cables could have been fried by then anyway!
Jeremy Davis
http://www.astad.org
|
|
|
|
|
Hi,
I would like to add a command ( menu or toolbar button), to my word automated app, and when the users presses over that toolbar button in word, then execute code of my application.
I have read that Ms Word has some sink interface, but only for some events like close/quit/Doc Change..., does it go further ?
Thanks, Bye !
Braulio
|
|
|
|
|
Has anybody any info how the mp3 playlist format is written, i.e. how the Length=xxx is calculated etc. Has any body maybe a Class to read/write to andfrom such a file? (win32 API/ATL/WTL if poss.)
Thanks in advance
|
|
|
|
|
is it this thing you're looking for ?
#EXTM3U
#EXTINF:270, ...
LENGTH=270 // it means that this song is 270 s long.
Fred
|
|
|
|
|
No, that format is for the *.m3u playlist format, If you have info for this that would be great as well
|
|
|
|
|
ok, so here another file, a .pls this time
[playlist] // head of the file
File1=(U2) Pride.Mp3 // mp3 file
Title1=(U2) Pride // how it will be displayed
Length1=227 // 227 stands for 227seconds (3min47)
...
NumberOfEntries=23 // total nb of files in the list
Version=2 // ?
the coding is pretty straightforward.
Fred
|
|
|
|
|
Thanks Fred, got it up and running now..
|
|
|
|
|
Do you know how to change the background color of a CDateTimeCtrl control ?
Thanks.
Where there is a WISH, there is a WILL.
|
|
|
|
|
Have you tried CDateTimeCtrl::SetMonthCalColor ? It allows great flexibility on which colors you can change.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Silly me. I took a look at the help on CDateTimeCtrl but I did not see this method.
Thank you. That should do the job. I try it right away. Thanks.
Where there is a WISH, there is a WILL.
|
|
|
|
|
Too bad. This is not really what I needed. SetMonthCalColor() only applies to the calendar that pops up when you click on the combo box'x arrow.
What I want to change is the background color of the EditCtrl-like control of the CDateTimeCtrl.
Thanks anyways.
Where there is a WISH, there is a WILL.
|
|
|
|
|
Maybe (not sure) this color can be changed the same way the background color of other controls (CStatic s, CEdit s) is. Check §4.9 of Mike Dunn's C++ FAQ. Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I built a dll with a simple function in it.
the question is:when i call the function using static linking,no error occur.
but when using dynamic linking,after the function execute complete,an error alway ocurred?
WHY?
the relative code is:
(1)with the dll project:
#include "math.h"
extern "C" __declspec(dllexport) double SquareRoot(double d)
{
CString strText;
if(d>=0.0)
{
strText.Format("%f",sqrt(d));
AfxMessageBox(strText);
return sqrt(d);
}
return 0.0;
}
(2)within the caller project:
*.h:
typedef double (WINAPI *TCSV2DVS)(double);
HINSTANCE m_hInstance;
TCSV2DVS FCSV2DVS;
*.cpp:
void CCallerDlg::OnButtonConvert()
{
m_hInstance = ::LoadLibrary("C:\\DLL\\CsvDvs\\Debug\\CsvDvs.dll");
if (m_hCsvDvs == NULL) {
AfxMessageBox("Load CsvDvs.dll error!");
}
FCSV2DVS = (TCSV2DVS)::GetProcAddress(m_hCsvDvs,"SquareRoot");
double ret = FCSV2DVS(9.0);
::FreeLibrary(m_hInstance);
}
Thanks advance.
(sorry for my poor english)
|
|
|
|
|
I guess the problem has to do with this two lines:
extern "C" __declspec(dllexport) double SquareRoot(double d) and
typedef double (WINAPI *TCSV2DVS)(double); Either include the WINAPI specifier in the first line or remove it from the second.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|