|
Hi Cedric,
Thanks for the help.
I've already done all that,but how do I look at the state of the variable m_pSendLock().
Can u tell me how to do this and can u also tell me what to expect,or any examples that u can give me will be very helpful.
Thanks,
Arjun.
Arjun Mukherjee
Software Engineer
Hewlett Packard
|
|
|
|
|
When your program is stopped on your breakpoint, right click on the variable, and click on QuickWatch. Then you will have a window that will show you the state (and value and mamber variables...) of your class. Look if it well instancied (the adress pointer must look something else than 0x000000 or 0xccccccc or 0xcdcdcdcd ...) something like a 'valid' adress (I cannot tell you what exactly is a 'valid' adress). If this is not the case, maybe your semaphore is not instancied...
|
|
|
|
|
aj1682 wrote:
I cannot understand the function pointer not rightfully initialised
Ususally this Case arise when we Dynamically Load Function from DLL usig LoadLibrary and GetProcAddress.
and Function Pointer is Not properly intialized.
aj1682 wrote:
the heap out of domain
Simple,when function tried to acces heap or memory location which out of it access or not properly initialized.
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
is the debugger pointing to the line of code that calls lockWait()? Are you sure that m_pSendLock was initialized properly? Usually, that type of crash is associated with a pointer that is A) uninitialized (not set to NULL by default) and B) never set to actually point to an object. xCDCDCDDD is the kind of number that variables sometimes get set to if they were never initialized to 0 or NULL in a class constructor. Always initialize pointers to 0. In this case, obviously, you have to set the pointer to point to some valid object.
Are you doing something like the below code to setup your pointer somewhere?
m_pSendLock = &theSemaphoreObject; or
m_pSendLock = new CSemaphore;
If so, what specifically are you doing to set the pointer? Is the crash occurring when your application exits? Another kind of situation that occurs is when you have a thread that doesn't terminate before your class is destroyed (on exit). The object gets destroyed but the thread continues to execuate and then trys to call a function with an invalid pointer.
|
|
|
|
|
Hi
Yeah the debugger is pointing to m_pSendLock->lockwait();when it gives me the error and breaks.
I checked the state of the m_pSendLock variable ,I dont think its initialised,even though I did initialize the class variable(that m_pSendLock is a prt of) to NULL,but it still din't work.
The constructor contains the code m_pSendLock = new CXSemaphore(...
But then I've used a previously declared and initialised pointer of the same class and then referenced m_pSendLock and all other methods,and it seems to work.I do not understand y so.Anyway, as of now I have solved the problem,even though I do not understand y and how.
Thanks a lot.
Arjun Mukherjee
Software Engineer
Hewlett Packard
|
|
|
|
|
For future reference, it sure would help to see some code snips of your class declaration, constructor implementation, and maybe some snips of where the instantiated object is used.
Regards,
Shawn
|
|
|
|
|
hi,
well the problem i am facing is that i have a class say A..which has the following declaration
class A: public CFontDialog
{
....
}
now in the initinstance of the dialog i want to get the resource id of dialog.
Can anyone please help me on the issue!
PS. i have tried GetWindowLong( GWL_ID )... but it returns 0. ......
please help.
lid.
|
|
|
|
|
|
well as i told earlier... i have this class manually defined and not defined against a dialog resource.... the member A::IDD you mentioned is defined by the new dlg wizard and is not present in case of CCustomDialogs more specifically CFontDialog ... so if you have anything else in mind. please update me..
thankx for the time and consideration.
lid
|
|
|
|
|
otherwise, you can have the hWnd pointer with :
CFontDialog fontDlg();
CWnd pWnd = fontDlg->m_hWnd;
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi
It might be in the CDialog::m_lpszTemplateName parameter.
HTH
Martin
|
|
|
|
|
Hi,
i have checked the m_lpszTemplateName parameter but its value is NULL..... anything else..???
please
|
|
|
|
|
Hi
What are you trying to do here?
The Dialog Resource is only used to create the dialog and once the dialog is running it's not accessed again - the same principle (barring contrived cases) applies to any dialog created from a resource template.
If you're trying to override the Font Dialog's default resource layout with your own, set the CFontDialog's m_cf.lpTemplateName data member to your adapted version of the standard Choose Font resource and work from there.
Martin
|
|
|
|
|
Hi,
This is almost exactly what i m trying to do over here... i have added my custom controls to the standard font dialog....? the problem is that when the windows DPI is changed to 120 some of the controls starts overlapping or the text is just bigger than the size of the control....i have found a code on code project which when provided the ID of the dialog makes all the controls of the dialog bigger according to the current DPI.
So, i was hoping to get the resource of the dialog somewho and pass it to the code downloaded from code project.....
BTW if the idea is silly and is not workable... do tell me ...so i could search for some other solution.
lid
|
|
|
|
|
Hello there,
How do I change the window style of Internet Explorer. I placed the browser control on a Dialog. When the page pops up the browser control gets 3d style. I want to change the style to flat. How do I do this??
vyjesh
|
|
|
|
|
Hello Friends,
Please tell me what is meant by Call back function. How it works and an example?
Thanks in advance.
Neelesh K J Jain.
|
|
|
|
|
Hi Neelesh,
A CallBack function is called by Operating system. The classic example of a callback function is WndProc() function in "Hello World" sample found in any Win32 Programming book.
Regards
Abhi Lahare
|
|
|
|
|
1. you have two functions : FunctionA and FunctionB.
2. you call FunctionA with a pointer to FunctionB.
3. FunctionA calls FunctionB as part of its processing, usually in a loop.
Software | Cleek
|
|
|
|
|
...Additionally callback functions can be very useful in event notification purposes.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
#pragma pack(push|pop)
From what I remember...the last time I read up on what this pragma does was long time.
Anyways...my understanding is that it forces a even byte alignment of structures, it's mebers, etc.
I've seen it used often in a structure and like I said...my understanding is that it causes data members to fall on quad byte boundries or whatever...for faster access times...
I think it's a CPU quirk that data accessed on an even 4 byte boundry is more efficient on 32 bit processers???
Sp my question is this...assuming I am correct in my above thinking...
Would it make a logical difference if I were to remove pragma's like this??? I find them annoying...and despite making code more efficient I'm not sure I think it's worth the harder to read code (I like things easy).
If this is the case...one more question:
The pragma surrounds structs which are then used in a MFC CArray...to holds potentially 1000's of elements...
So does this pragma make sure each of those elements will be accessed on an even byte boundry???
Or I guess...would it atleast make sure the first struct item in array was on an even byte boundry, so the rest that followed???
One more question:
If a struct was 5 bytes would this pragma actually allocate 8 bytes for a single element, in this case using more memory in the trade off of speed in access times???
so 2 elements would actually consume 16 bytes instead of 10? wasting 3 bytes, but causing each to fall on even byte boundries???
Just curious...hope i'm on the right track here
Thanks in advance
It's frustrating being a genius and living the life of a moron!!!
|
|
|
|
|
Hi
I agree with your concern about unnecessarily optimizing the runtime memory layout of C++ entities, and that byte-alignment in this case should enjoy less limelight than more important issues of software development.
However, I've had the need to use the packing pragma - typically in scenarios where I'm overlaying a C++ struct on a data byte array. For example, receiving a packet over the network - it's packed tightly by another program that is not necessarily concerned with extra byte-padding - and overlaying a C++ struct on top of that in order to interpret the elements contained in the data. Another example would be reading byte streams from a file.
Unless you're responsible for both consumer and provider of such byte sources, you'll have to be careful that the not-so-obvious extra padding of default byte-alignment doesn't cause problems (getting byte streams and C++ struct members out of sync) - because they are very tricky to find.
HTH
Martin
|
|
|
|
|
Yes that is example when pragma pack's are needed. I need them when I'm reading some structure from disk file. If i would not pack it, variables in the structure would have 'byte gaps' between themselves, and structure would be read incorrectly.
|
|
|
|
|
its typically used to 'pack' a structure into a certain byte alignment because otherwise the structure gets padded out automatically and things either use up more memory than necessary OR saving and loading mechanisms (particularly on cross platform code or tool development (e.g. 16 bit machines etc.)) end up reading in the wrong amount of data and so the struct it loads is full of rubbish.
However, my experience with #pragma pack is that its the most idiotic compiler directive i have seen. You can specify a struct with size 16 bits (using bit fields of type 'unsigned') specify a #pragma pack directive of 2 bytes (so the size of the struct should be 2 bytes in memory) and yet it fails badly and instead aligns it on a 4 byte boundary ! ! Change the unsigned type to unsigned short and it chucks it on a 2 byte boundary, hooray ! !
My verdict :
Its absolute rubbish.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
"I think it's a CPU quirk that data accessed on an even 4 byte boundry is more efficient on 32 bit processers???"
That's correct and the P4 is really horrendous at it. P3s and AMD processors have an easier time of it.
Actually, the default packing of data structures is to the size of the item ie., doubles are aligned to the nearest eight-byte boundary, ints on a four-byte boundary, and shorts on a two-byte boundary.
From MSDN : "If you use #pragma pack without an argument, structure members are packed to the value specified by /Zp. The default /Zp packing size is /Zp8."
I do a lot of work with communications in various manners and we often use pack(1) insure that the data that we transfer is aligned correctly. If the processor has difficulties with that then we just have to deal with it.
|
|
|
|
|
Hi,everyone:
i access my data of Doc using following code:
<br />
CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd(); <br />
ASSERT(pMainFrmWnd != NULL); <br />
<br />
CWnd* pchildWnd = pMainFrmWnd->GetWindow(GW_CHILD);<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
<br />
CvcydcjView *pMyView = NULL; <br />
while(pchildWnd->GetSafeHwnd() != NULL)<br />
{<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
if(pchildWnd->GetRuntimeClass()->m_lpszClassName == "CvcydcjView")<br />
{<br />
pMyView = (CvcydcjView*)pchildWnd;<br />
break;<br />
}<br />
pchildWnd = pchildWnd->GetWindow(GW_HWNDNEXT);<br />
}<br />
ASSERT(pMyView != NULL);<br />
<br />
CvcydcjDoc *pMydoc;<br />
pMydoc=pMyView->GetDocument();<br />
ASSERT(pMydoc != NULL);<br />
<br />
pMydoc->MyData="demo";<br />
but when i use it in a thread, it didn't work, it seems stopped at
pMydoc=pMyView->GetDocument();<br />
can you give me some suggestions? Thx!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|