|
How can i bring MAC style to the UI of my application developed using VC++6.0.Is there any method to tweeking the code so as to optain such an interface?if any free libraries are avaliable to optain such output please do specify that to...!
Thankyou
|
|
|
|
|
|
I'm new to Visual C++ and trying to learn it. I've written a Windows program from the ground up and I'm trying to add a status bar to my dialog window but I get a compile error:
...\489window.cpp(14): error C2228: left of '.SetPaneText' must have class/struct/union type
Here's my declaration and code with the offending line at the end, the static void declaration:
<br />
public:<br />
CStatusBar m_bar;<br />
static void setStatusBarText(CString newText){ m_bar.SetPaneText(NULL, newText, true); }
I have a menu and when the user clicks "Open..." in the menu, they get the open file common control and once the file has been chosen, my program fetches two fields, a height and width of the bitmap image and it should then set the status bar to be "<width> x <height>" with the numbers filled in.
Where the program does this is in a class I derived from CWinApp, but the codeproject.com example I found places the status bar declaration in the class derived from CWnd (I derived my dialog from CFrameWnd from using another example somewhere) which is where the above code is copied from. It's acting like it doesn't know what m_bar is because I can try and retype the m_bar.Create(...) line but once I hit the period, it tells me m_bar isn't a union, class or struct, but it was declare the line above it. Any help is appreciated, but please remember I'm new and need something easier to understand than most. Thanks in advance.
more:
I just adedded the create line in the constructor for my CFrameWnd derived class and it knows m_bar. I commented out the offending line above, so I just have the declaration and the create. I ran the program and it created the status bar and it looks just fine. I still get that error above.
|
|
|
|
|
Remove the static keyword from your function prototype and it should work.
The static declaration means that your function does not exist with the instance of your class, therefore will be unaware of any member functions.
I Dream of Absolute Zero
|
|
|
|
|
I think I started out without static and then I encountered this error:
...\489window.cpp(64): error C2352: 'C489guiFrame::setStatusBarText' : illegal call of non-static member function
And here's the line for that:
C489guiFrame::setStatusBarText(sizeInfo);
Here's the changed prototype:
void setStatusBarText(CString newText){ m_bar.SetPaneText(NULL, newText, true); }
I ran into that error before, that's why I tried the static keyword.
|
|
|
|
|
You need to have an instance of C489guiFrame
LighthouseJ wrote:
C489guiFrame::setStatusBarText(sizeInfo);
then becomes
C489guiFrame myGUIFrame;<br />
<br />
myGUIFrame.setStatusBarText(sizeInfo);
or something similar.
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)
|
|
|
|
|
But wouldn't that create another window? I have this also in the file, doesn't this create the window?
<br />
class C489guiApp: public CWinApp {<br />
public:<br />
BOOL InitInstance() {<br />
m_pMainWnd = new C489guiFrame;<br />
m_pMainWnd->ShowWindow(SW_SHOW);<br />
m_pMainWnd->UpdateWindow();<br />
<br />
return TRUE;<br />
}<br />
...<br />
}<br />
When I want to set the text, can't I say m_pMainWnd->setStatusBarText(sizeInfo); ? I'm trying that which should be in my derived class but it's not in the little list.
|
|
|
|
|
LighthouseJ wrote:
But wouldn't that create another window?
My intension was to give an example of how to access a non-static member function. Sorry if this was confusing.
OK given the information you have supplied.
The problem is that m_pMainWnd is a pointer to a CWnd object. You need to cast it to a C489guiFrame object.
You can either do
C489guiFrame* pFrame = reinterpret_cast<C489guiFrame*>(m_pMainWnd);<br />
ASSERT(pFrame != NULL);
from within the CWinApp derived class
or
C489guiFrame* pFrame = reinterpret_cast<C489guiFrame*>(AfxGetMainWnd());<br />
ASSERT(pFrame != NULL);
from other classes
then use pFrame to call its member function
pFrame->setStatusBarText(sizeInfo);
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)
|
|
|
|
|
How can I disable MRU list from my SDI application. I have tried ON_UPDATE_COMMAND_UI_RANGE and ON_UPDATE_COMMAND_UI but nothing seems to work. when I put these message handlers, the MRU list totally vanishes. I am a bit stuck here.
Nick in Progress
My Articles
|
|
|
|
|
Hi,
First you call CWinApp's LoadStdProfileSettings(0) in InitInstance. And remove all MRU menu items from the resource menus.
Regards,
Selvam
|
|
|
|
|
I know this method but I wanted to disable the MRU items temporarily during some operation. By doing this, it will show and MRU list with 0 items so its of no use to me.
Anyways, I have done this by writing a custom Message Handler.
Thanx for your response.
Nick in Progress
My Articles
|
|
|
|
|
Hi:
I need to capture an image made in my window (with MoveTo and LineTo functions) and stretched it to another size.
How can I make it?
thanks,
|
|
|
|
|
|
Thanks,
but is it not another easier solution without saving first the image to a file?
|
|
|
|
|
Hello everybody!
I´m using CreateProcess to create a new process, with the CREATE_NEW_PROCESS_GROUP
flag set in the argument "dwCreationFlags", to create a new process group.
Let´s call PROCESS_A the one which calls CreateProcess, and PROCESS_B
the one which is created.
MSDN says in "CreateProcess" function:
------------------------------------------------------
CREATE_NEW_PROCESS_GROUP:
The new process is the root process of a new process group. The process
group includes all processes that are descendants of this root process.
The process identifier of the new process group is the same as the process
identifier, which is returned in the lpProcessInformation parameter.
Process groups are used by the GenerateConsoleCtrlEvent function to enable
sending a ctrl+c or ctrl+break signal to a group of console processes.
------------------------------------------------------
I know that from PROCESS_A, I can get the PID of the PROCESS_B through
"lpProcessInformation", which is also the identifier of the new process
group. I also know that "GetCurrentProcessID" returns the PID of the
current process.
But I need that PROCESS_B knows the ID of its own process group, without
having to pass it in the command line arguments, when CreateProcess
is called.
-Is it possible to get the ID of a process group?
-How can PROCESS_B know the identifier of its own process group?
(without passing it in the command line when CreateProcess is called)
-Is there any function which returns process group ID of the calling
process, like "getpgid(0)" in Linux does?
Thanks all!.
|
|
|
|
|
Maybe I am not reading this correctly, but isn't this already your answer?
I know that from PROCESS_A, I can get the PID of the PROCESS_B through
"lpProcessInformation", which is also the identifier of the new process
group.
If the PROCESS GROUP ID is the same as the PROCESS ID for your ProcessB, then from within the ProcessB, just call GetProcessID() and that should match the process group identifier. Doesn't your statement above imply the new process group id is the same as the processB process identifier
MSND says same thing:
"The process identifier of the new process group is the same as the process identifier, which is returned in the lpProcessInformation parameter."
|
|
|
|
|
Unhandled exception at 0x0044c743 in NewMumsEngine.exe:0xC0000005: Access violation reading location 0xcdcdcddd.
This arises in the msgSendQueue method,when I use the semaphore class variable m_pSendLock to access the lockWait()method :
m_pSendLock->lockWait();
This happens after the script has been loaded and when the message has to be sent to the queue to be stored.We need to lock to allow only one thread access at a time.
Can anyone tell me how to solve this pr atleast what this sort of an error means.
Arjun Mukherjee
Software Engineer
Hewlett Packard
|
|
|
|
|
Hi There!
I think this type of error ususally come when Function pointer is not rightfully initialized or it try to use heap that out of it domainian.
aj1682 wrote:
m_pSendLock to access the lockWait()method :
m_pSendLock->lockWait();
Have you check m_pSendlock is rightfully
intialized,before calling of m_pSendLock->lockWait();
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi Alok,
Thanks for the help.
I checked the initialization,m_pSendLock is a semaphore class variable and this is initialised in another class.
I have declared a variable of this class and included the semaphore initialization in the constructor of this class.
then I have used this variable to access the function of this class where the statement
m_pSendLock->lockwait();
is used.
So i guess the constructor does the initialization of the semaphore class variable.
But I cannot understand the function pointer not rightfully initialised,or the heap out of domain.can u please explain this to me a little and tell me how to check it or any other way.
thanks,
arjun.
Arjun Mukherjee
Software Engineer
Hewlett Packard
|
|
|
|
|
Put a breakpoint (F9) just at the line m_pSendLock->lockwait(); and then debug your program (F5). Look at the state of the variable m_pSendLock to check if everything is correct.
|
|
|
|
|
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
|
|
|
|