|
#define OFF(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field)) Take the following structure:
struct ThisStruct
{
char field1;
short field2;
int field3;
int field4;
}; If we call the macro as such: OFF(ThisStruct, field3)
Firstly, the macro creates a pointer to a ThisStruct structure at address 0: ((ThisStruct *)0)
Next, it refers to a particular field inside that structure: ((ThisStruct *)0)->field3
Next, it takes the address of that field: &(((ThisStruct *)0)->field3)
Since field3 is 3 bytes from the beginning of the structure, and the structure is at address 0, the pointer will hold the value 3.
Lastly, the macro converts the pointer to a LONG_PTR and finally to a LONG , to give an integer result - the offset of the field from the beginning of the structure.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
How can I change it???
I have looked into MFC and found ASSERTMSG, but this macro isn't defined when I build, and if I include it's header in which it is defined bh.h??? I get a million error messages
Any ideas?
Thanks
How do I print my voice mail?
|
|
|
|
|
I am trying to add some error handling to my project and I want to exit if either the configuration file from the command line doesn't exist or the configuration file has parsing errors. I have tried the code below using Visual Studio 2003 (MFC Dialog based application). The application does not exit. What is the correct way to force a shutdown of my MFC Dialog based application?
<code>
if( InitDOM( XMLFileName ))
{
if( !ParseDOM() )
{
CString msg;
msg.Format("Invalid node fetched.\n%s\n", (LPCSTR)pXMLDom->parseError->Getreason());
AfxMessageBox( msg );
PostQuitMessage(0);
}
else
{
ProcessPanels();
}
}
else
{
AfxMessageBox( " config file did not exist" );
PostQuitMessage(0);
}
</code>
|
|
|
|
|
Try EndDialog()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I tryed this and it does not exit cleanly. I will look into it some more tomorrow as it is quite late at the moment.
|
|
|
|
|
smesser wrote:
I tryed this and it does not exit cleanly.
How so? This is how modal dialogs end. Modeless dialogs use a different approach.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I have not had a chance to look into it but I have a cleanup function and there are some calls to Killtimer that are crashing. What happens when you call Killtimer on a timer that was never set to begin with?
|
|
|
|
|
smesser wrote:
What happens when you call Killtimer on a timer that was never set to begin with?
Then KillTimer() should not be called. Use the return value of SetTimer() to know if the timer exists or not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I will have need to do this in a modeless dialog as well. What is the technique for that?
|
|
|
|
|
Modeless dialogs do not use DoModal() or EndDialog() . See MSDN for examples.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
try OnClose();
TOXCCT >>> GEII power
|
|
|
|
|
Hello, everyone!
I am looking for source code of Web search engine. I just want basic functions of a Web search engine, just key word search is enough. Rank, classification and other advanced functions are not need. I want the search engine to work in this way, download web pages from specified web sites to local machine, then the search engine can retrieve information from local machine.
Where can I find related source codes?
Best regards,
George
|
|
|
|
|
|
Thanks, d2hes buddy!
I have searched "sourceforge.net" by key word "Web Search Engine" but failed to find any useful information. What better key word should I use?
Best regards,
George
|
|
|
|
|
depends how automated you want it...
It's pretty easy to download files from a remote source and it's just as easy to open a file and look for keywords using regex...so no one has probably bothered to build such a thing...beside it's kind of a makes no sense under most circumstances type project...
Anyways, look at building your own...there is a function whose name escpaes me right now that is availble with IE 4+ or something like that, which make downloading files a snap...then just look into boost::regex++ for extarcting keywords and such...
Wouldn't be to hard...
Cheers
How do I print my voice mail?
|
|
|
|
|
Thanks, Hockey buddy!
The method you mentioned is an effective one. Can you tell me where can I find source codes which can download the whole content of a Web site. I think to make a reference to some source codes written by experienced people will contribute a lot when making a new one by myself in the future.
Best regards,
George
|
|
|
|
|
I'm looking for a way to change some of the default configuration settings that are generated for c++ projects in .Net 2003. (i.e. I want Level 4 warnings, I want my output sent to a /bin folder, etc.)
I could have sworn I came across material at one time stating that there was a master template file (.xml file maybe?) for this, but I haven't been able to find anything.
Any ideas?
Thanks for any help.
"You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb
|
|
|
|
|
I have found what I'm looking for.
Thanks self.
"You will be killed by a poisoned fortune cookie." - Old fortune cookie proverb
|
|
|
|
|
Can anyone please help me!!
i am looking for some simple C++ code to validate isbn numbers. i have no clue where to start
THANK-YOU!!
James
|
|
|
|
|
|
|
i want to modify the window caption,i know to use
AfxGetMainWnd ( ) —> SetWindowText (_T("Application title") )
but when i write it in BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
but when i doesnt run note warning box
|
|
|
|
|
you can not use AfxGetMainWnd ( ) —> SetWindowText (_T("Application title") ) in PreCreateWindow because as the method name indicates that the window has not yet been created so the call will fail or will not work.
Regards.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
first i create button control in tool,id:IDP_PLACEHOLDER2
second:derive a CMainToolBar from ctoolbar
in mainfrm.h declare CMainToolBar m_wndToolBar;
in MainToolBar:public:CComboBox m_wndSnap;
in mainfrm.cpp oncreate:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{#define SNAP_WIDTH 80 //the width of the combo box
int index;
CRect rect;
//set up the ComboBox control as a snap mode select box
//
//First get the index of the placeholder's position in the toolbar
index = 0;
while (m_wndToolBar.GetItemID(index) != IDP_PLACEHOLDER2) index++;
//next convert that button to a seperator and get its position
m_wndToolBar.SetButtonInfo(index, IDP_PLACEHOLDER2, TBBS_SEPARATOR,
SNAP_WIDTH);
m_wndToolBar.GetItemRect(index, &rect);
//expand the rectangle to allow the combo box room to drop down
rect.top+=2;
rect.bottom += 200;
// then .Create the combo box and show it
if (!m_wndToolBar.m_wndSnap.Create(WS_CHILD|WS_VISIBLE|CBS_AUTOHSCROLL|
CBS_DROPDOWNLIST|CBS_HASSTRINGS,
rect, &m_wndToolBar, IDC_SNAP_COMBO))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndToolBar.m_wndSnap.ShowWindow(SW_SHOW);
//fill the combo box
m_wndToolBar.m_wndSnap.AddString("SNAP OFF");
m_wndToolBar.m_wndSnap.AddString("SNAP GRID");
m_wndToolBar.m_wndSnap.AddString("SNAP RASTER");
m_wndToolBar.m_wndSnap.AddString("SNAP VERTEX");
m_wndToolBar.m_wndSnap.AddString("SNAP LINE");
m_wndToolBar.m_wndSnap.SetCurSel(0);
return 0;
}
,in fact,the program above is from randymore in cp articles.why when i compile no error,but when i run,pop a waring box.
the below is debug info:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\system32\MFC42D.DLL'
Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded symbols for 'C:\WINDOWS\system32\MFCO42D.DLL'
Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mfc42loc.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hookdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:\WINDOWS\system32\PINTLGNT.IME', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (HOOKDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.0.0_x-ww_1382d70a\comctl32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\MyWebSearch\bar\1.bin\MWSOESTB.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\version.dll', no matching symbolic information found.
Detected memory leaks!
Dumping objects ->
strcore.cpp(118) : {72} normal block at 0x00421240, 23 bytes long.
Data: < 517t> 01 00 00 00 0A 00 00 00 0A 00 00 00 35 31 37 74
strcore.cpp(118) : {71} normal block at 0x00421290, 71 bytes long.
Data: < : : 517t> 01 00 00 00 3A 00 00 00 3A 00 00 00 35 31 37 74
F:\control learing\517toolbar\MainFrm.cpp(18) : {70} client block at 0x00421310, subtype 0, 544 bytes long.
a CMainFrame object at $00421310, 544 bytes long
F:\control learing\517toolbar\517toolbarDoc.cpp(18) : {69} client block at 0x00421560, subtype 0, 84 bytes long.
a CMy517toolbarDoc object at $00421560, 84 bytes long
plex.cpp(31) : {68} normal block at 0x004215E0, 124 bytes long.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
Data: < ` B > 00 00 00 00 00 00 00 00 00 00 00 00 60 17 42 00
{67} First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
client block at 0x00421690, subtype 0, 32 bytes long.
a CDocManager object at $00421690, 32 bytes long
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
strcore.cpp(118) : {66} First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
normal block at 0x004216E0, 71 bytes long.
Data: < : : 517t> 01 00 00 00 3A 00 00 00 3A 00 00 00 35 31 37 74
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
F:\control learing\517toolbar\517toolbar.cpp(76) : {65} First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
client block at 0x00421760, subtype 0, 108 bytes long.
a CSingleDocTemplate object at $00421760, 108 bytes long
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
strcore.cpp(118) : {63} First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
normal block at 0x00421800, 19 bytes long.
Data: < File> 01 00 00 00 06 00 00 00 06 00 00 00 46 69 6C 65
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
strcore.cpp(118) : {62} First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (MSCTF.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
normal block at 0x00421840, 29 bytes long.
Data: < Rece> 01 00 00 00 10 00 00 00 10 00 00 00 52 65 63 65
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
{61} normal block at 0x00421890, 20 bytes long.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in 517toolbar.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
Data: < L_ L_ L_> 04 00 00 00 14 CB 4C 5F 14 CB 4C 5F 14 CB 4C 5F
{60} normal block at 0x004218D0, 32 bytes long.
Data: << K_ B L B > 3C 8D 4B 5F 04 00 00 00 94 18 42 00 4C 18 42 00
Object dump complete.
The thread 0x520 has exited with code 3 (0x3).
The program 'F:\CONTROL LEARING\517toolbar\Debug\517toolbar.exe' has exited with code 3 (0x3).
,can someone give me some instruction ,i am puzzled.thx all.
|
|
|
|
|