|
Ummm... Looks weird. If you try debugging the app, where exactly the error shows up? On exiting from d2.DoModal() ? Upon entering d2.GetNumber() ? Inside that method?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It was return number in d2.GetNumber().
now I got no bug anymore.. I put UpdateData(FALSE) in OnOK() then it work.. still i don't know why though.
I have 2 CString member variable in dlg2 class. one is IDC_NUMBER ( edit box to accept the input number ) variable and the other regular CString just to store back the input number.
As you see how i did in dlg2::ONOK().
why do I have to call UpdateData(FALSE) to get rid of the bug eventhough GetNumber() is not returning IDC_NUMBER CString variable but regular CString variable member of the dlg2 class???
|
|
|
|
|
Hi everyone. I got a little issue , and I'd like to see what kind
of suggestions you all have to help me solve it
Ok, first some background info.
The project im building is in C++. It uses a Third-Party API.
Basically, its neccesary for me to read in the contents of a file, and pass the entire contents of this file into the 3rd parties API function.
Now , heres where the problem arises.
The API expects to recieve the file contents as a Char variable, but sometimes the file size I need to pass is bigger than a char variable can hold!
Somehow I need to get the entire contents of my file into the api as a char value, just not sure how im going to go about doing this.....
Any suggestions / workarounds , etc. would be greatly appreciated!
Thanks,
Josh
|
|
|
|
|
|
Hi Gang,
I was just wondering if somebody has a vc example of a multiview single document program? What I want to do is to have two different types of views represent the same document class. One view might be a bunch of items, like a map coordinate system, and the other view might actually have a tree view of the addresses of the houses. The document is the list of houses itself with something like names, addresses, (coordinate system to display them with).
Thanks,
Nick
|
|
|
|
|
I am Microsoft Speech 5.1 (SAPI) and I am having a problem. For some reason LoadCmdFromResource is failing. I have the .cfg as a resource in a folder "SRGRAMMAR" and I am pretty sure all my parameters are correct but why is it failing?
hr = CmdGrammar->LoadCmdFromResource(
NULL,
MAKEINTRESOURCEW(IDR_QCDGRAMMAR),
L"SRGRAMMAR",
MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL), SPLO_STATIC);
if ( FAILED( hr ) ) //Leave application
{
DestroyWindow(hVoice);
CoUninitialize();
return FALSE;
}
|
|
|
|
|
I'm puzzled: FuelGauge is a CIndicator object.
I had:
class CIndicator
{
private:
double mMaxLimit;
double mCurValue;
double mMinLimit;
public:
CIndicator(double MaxLimit = 100.0,
double startValue = 0.0,
double MinLimit = 0.0);
~CIndicator();
CIndicator (const CIndicator& ind);
void Display (CString s) const;
double SetValue (double value);
double GetValue () const;
BOOL IncreaseBy(double value = 1.0);
BOOL DecreaseBy(double value = 1.0);
};
sizeof( FuelGauge) turns out to be 24.
When I added a virtual in front of the function Display(), I got sizeof = 32! Its due to the Vtable I understand, but how do I find out the size of the address of the VTable? Do all addresses have the same size? Its looks like its 8, but why is that? Does the address size depend on the kind of object thats being stored there? If so, what kind of object is the VTable object?
Appreciate your help,
ns
|
|
|
|
|
First off, you really shouldn't care about the vtable since it can change from implementation to implementation.
Now, for the information you requested.
A VTable is just a pointer to an array of function pointers. In MSVC, this pointer is at the start of the structure or class. It will be 4 bytes wide. The reason that your structure is 32 bytes in size is that doubles are naturally aligned and thus must be on an 8 byte boundary. This means that 4 bytes of padding after the vtable is required to align the first double. Thus, 3 * 8 + 4(vtable) + 4(pad) = 32
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks. Experimenting to understand this padding concept I added an int to my class. Now sizeof is 40! So its
3*8 + 4 (int) + 4 (pad) + 4(vtable) + 4(pad)?
Cant test this out easily, but what if I'd had all ints in my class, and no doubles. would I still be doing the 8 byte boundary (I cant check it out because if I change all the doubles to ints, the program wont compile.) Would I get sizeof as 40 again?
Trying to undersatnd the 8 byte boundary concept.
Appreciate your help,
ns
|
|
|
|
|
Ints only require 4 byte alignment. So everything will look as expected without any extra padding.
HOWEVER, if you follow and int by a double, there is a good chance the double will have to have padding added before it. The same is true if an int is at the end of a structure that contains doubles. The end of the structure is padded to help make sure that an array of that structure is properly aligned.
Look up "Natural alignment" on google. VC uses natural alignment up to the double.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
VTs are automatically included by the compiler into the object code. Usually, one should not be concerned about the size or the locations of (pointers to) VTs, and in fact messing with them can only be done through non-standard casts.
Objecs have as many VT pointers as virtual classes they are derived from, roughly speaking. If you still are curious about implementation of these things in VC++, please tell me, I found once a very good article on VC++ object layout (but I don't recall where it was right now).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The article I'm reading just wanted to explain why virtual functions work...doesnt say to mess with the VTable. They said the structure gets additional info because the VTables address gets added in. So rest assured, I dont plan to mess with it , just trying to see how the magic of virtual functions happens..
Appreciate your help,
ns
|
|
|
|
|
I found the article: C++: Under the Hood[^] (courtesy of Nemanja Trifunovic).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
THat looks really informative
Appreciate your help,
ns
|
|
|
|
|
I created a toolbar using CToolBar and I would like to update its compile-time tool tips at run time. The toolbar is created with:
m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.LoadToolBar(IDR_MAINFRAME);
I assumed that the following would allow me to retrieve and modify its list of tool tips:
CToolBarCtrl* m_pToolBarCtrl = &m_wndToolBar.GetToolBarCtrl();
CToolTipCtrl* m_pToolTipCtrl = m_pToolBarCtrl->GetToolTips();
But it doesn't work - m_pToolTipCtrl is set to zero. How should I update my tool tips??
Steve
|
|
|
|
|
Where in your code are you calling GetToolBarCtrl . If in the constructor of your dialog or frame, this is too early. Try in OnInitDialog .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I was calling in OnCreate. I tried placing these lines in a button handler, and m_pToolTipCtrl still gets set to NULL.
CToolBarCtrl *m_pToolBarCtrl = &m_wndToolBar.GetToolBarCtrl();
CToolTipCtrl *m_pToolTipCtrl = m_pToolBarCtrl->GetToolTips();
Any ideas?
Steve
|
|
|
|
|
Issue a UpdateData(FALSE) call before attempting to obtain the toolbar control.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi. I would like to create a property sheet that can be used in several different situations. Instead of putting all my cases as separate tabs on the same sheet (there will be more than 7 pages and can grow beyond that), I would like to create a property sheet that can dynamically (???) add a page to the sheet.
I will have the following pages:
Basic Data (appears on all sheets)
Page 1
Page 2
...
Page 7
I would like to have my sheet used dynamically so that if I want "Basic Data" and "Page 1", I just add Page 1. If I want "Basic Data" and "Page 7", I just switch out my previous page and replace it with Page 7. There will only be two pages on the sheet at one time. Is this easy? Is this good?
I could probably try doing it with an expanding single dialog, but the dialog would be rather big and not appear as neat. Would this be simpiler to manage?
Any opinions or place I should look for help?
Thank you,
John
|
|
|
|
|
Maybe you can take advantage of CPropertySheet::AddPage and CPropertySheet::RemovePage .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
as Joaquín said, use that functions and pass a bit mask as a parameter for the contructor in order to decide which pages you want to show.
Last week I used XML documents and the CArray class in order to create dynamic property sheets, and in the contructor I pass the xml document path as an extra parameter.
Hope this enlights you a little bit...
|
|
|
|
|
When debugging my program I receive an 'Unhandled exception in Kernel32.dll 0xC0000005 : Acces violation", and the debugger stops at the next instruction:
lock xadd dword ptr[ecx], eax
Any start point to find out the wrong code?
Thanks.
|
|
|
|
|
Look at the call stack. It looks like a code calling InterlockedExchangeAdd on a NULL pointer, but you may not be calling this directly, it may be a library or a function you're using.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
void CIa_notesDlg::PrintNotes()
CPrintDialog dlg(FALSE);
if (dlg.DoModal() != IDOK)
return;
HDC hPrinterDC = dlg.GetPrinterDC();
if (hPrinterDC == NULL)
AfxMessageBox("Printer not found"/*IDS_SCRIPT_PRINTER_NOT_FOUND*/,MB_OK|MB_ICONSTOP);
else
{
FORMATRANGE fr;
int nHorizRes = GetDeviceCaps(hPrinterDC, HORZRES);
int nVertRes = GetDeviceCaps(hPrinterDC, VERTRES);
int nLogPixelsX = GetDeviceCaps(hPrinterDC, LOGPIXELSX);
int nLogPixelsY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
LONG lTextLength; // Length of document.
LONG lTextPrinted; // Amount of document printed.
// Ensure the printer DC is in MM_TEXT mode.
SetMapMode ( hPrinterDC, MM_TEXT );
// Rendering to the same DC we are measuring.
ZeroMemory(&fr, sizeof(fr));
fr.hdc = fr.hdcTarget = hPrinterDC;
// Set up the page.
fr.rcPage.left = fr.rcPage.top = 0;
fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440;
fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440;
// Set up 1" margins all around.
fr.rc.left = fr.rcPage.left + 1440; // 1440 TWIPS = 1 inch.
fr.rc.top = fr.rcPage.top + 1440;
fr.rc.right = fr.rcPage.right - 1440;
fr.rc.bottom = fr.rcPage.bottom - 1440;
// Default the range of text to print as the entire document.
fr.chrg.cpMin = 0;
fr.chrg.cpMax = -1;
DOCINFO di;
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("(Notes)");
di.lpszOutput = NULL; // Do not print to file.
StartDoc(hPrinterDC, &di); // Start the document.
lTextLength = m_notesExistantes.GetTextLength();
do {
StartPage(hPrinterDC); // Start the page.
// Print as much text as can fit on a page. The return value is
// the index of the first character on the next page. Using TRUE
// for the wParam parameter causes the text to be printed.
#ifdef USE_BANDING
lTextPrinted=m_notesExistantes.FormatRange(&fr,FALSE);
m_notesExistantes.DisplayBand(&fr.rc);
#else
lTextPrinted=m_notesExistantes.FormatRange(&fr,TRUE);
#endif
EndPage(hPrinterDC); // Print last page.
// If there is more text to print, adjust the range of characters
// to start printing at the first character of the next page.
if (lTextPrinted < lTextLength)
{
fr.chrg.cpMin = lTextPrinted;
fr.chrg.cpMax = -1;
}
} while (lTextPrinted < lTextLength);
// Tell the control to release cached information.
m_notesExistantes.FormatRange(NULL,0);
EndDoc (hPrinterDC);
}
-------------
-= Nasty_p =-
|
|
|
|
|
You might want to give us a bit more details about your problem. Does the code compile? Does it run? What happens when it runs? What does it print? etc.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|