|
I believe he wants to generate these ID's at runtime.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Your are right, I missed that.
Thanks for the help,
Bill
|
|
|
|
|
Once you have used ON_COMMAND_RANGE etc to map where the messages goto, you can use CMainFrame:GetMessageString to provide the status bar prompt and tooltips.
Example code from an app of mine is:
void CMainFrame::GetMessageString( UINT nID, CString& rMessage ) const
{
if (nID >= REFINESCRIPT_MENU_START_ID && nID <= REFINESCRIPT_MENU_END_ID)
{
rMessage = refineDLL[theApp.nIDtoRefineID[nID - REFINESCRIPT_MENU_START_ID]].DLLMenuStatusBarPrompt(nID /*theApp.nIDtoMenuID[nID - REFINESCRIPT_MENU_START_ID]*/) ;
// remove any tooltip
if (rMessage.Find('\n') >= 0)
rMessage = rMessage.Left(rMessage.Find('\n')) ;
}
else if (nID == ID_TOOLBAR_UNDO || nID == ID_TOOLBAR_REDO)
{
// need to get the active document
CDocTemplate *pTemplate;
CRefineDoc *pDoc = NULL ;
POSITION pos;
bool found = false ;
pos = AfxGetApp()->GetFirstDocTemplatePosition();
do {
pTemplate = (AfxGetApp()->GetNextDocTemplate(pos));
POSITION pos2 ;
pos2 = pTemplate->GetFirstDocPosition();
if (pos2 != NULL)
{
// loop through looking for the active docuement
do {
pDoc = (CRefineDoc*)pTemplate->GetNextDoc(pos2);
if (pDoc->m_bActiveDocument)
found = true ; // found it!
} while (!found && pos2 != NULL) ;
}
} while (!found && pos != NULL) ;
if (pDoc != NULL)
{
CString command ;
if (nID == ID_TOOLBAR_UNDO)
{
// get the undo message text
pDoc->GetUndoText(command) ;
rMessage.Format("Undo command \"%s\"", command) ;
}
else
{
// get the redo message text
pDoc->GetRedoText(command) ;
rMessage.Format("Redo command \"%s\"", command) ;
}
}
else
CMDIFrameWnd::GetMessageString(nID, rMessage) ;
}
else
{
// check to see wether the nID is part of one of the loaded toolbars.
// it it is, we need to load the string from that dll's resources
bool found = false ;
for (int i = 0 ; i < m_ToolbarCount ; i++)
{
if (m_pTB[i]->CommandToIconIndex(nID) >= 0)
{
found = true ;
// get the string from the DLL
rMessage = refineDLL[m_DLLIndexes[i]].DLLMenuStatusBarPrompt(nID) ;
// split the text at an \n
if (rMessage.Find('\n') >= 0)
rMessage = rMessage.Left(rMessage.Find('\n')) ;
}
}
if (!found)
CMDIFrameWnd::GetMessageString(nID, rMessage) ;
}
}
In the function:
REFINESCRIPT_MENU_START_ID = start of the command range allocated
REFINESCRIPT_MENU_END_ID = end of comamnd range allocated
The above code is used in a project where dynamically loaded DLL's are used, which also add menu options etc in. New toolbars may also have been added to the UI.
Hope its of help.
BTW GetMessageString is a virtual function you can override
|
|
|
|
|
I'd use AfxExtractSubString (just like MFC does) for extracting status bar prompt
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Can anyone please tell me how to make a CFormView object to
a non resizable window?
Thanks.
Aviv.
avivhal
|
|
|
|
|
Override the OnSize() message in your view and just don't pass the message on to the base class.
You may have to have a variable that indicates that the window is being initialized so that you can pass the size info along, and NOT to pass it along any other time.
1) Define a private boolean var in your class definition like so:
BOOL m_bAllowResize;
2) In the view constructor, do this:
m_bAllowResize = TRUE;
3) At the end of OnInitialUpdate() do this:
m_bAllowResize = FALSE;
4) In your OnSize function, do this:
if (!bAllowResize) { return; }
I haven't tried this, and you may have to try moving some of the code I listed above around in the class, but in theory, this should be close to what you want.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Hi,
I used these functions in a demo project:
void CDemoView::FormViewToDialog()
{
CWnd* pParent = GetParent();
CRect rect;
GetTotalClientRect(&rect);
DWORD style = pParent->GetStyle() & ~WS_THICKFRAME | WS_DLGFRAME;
::AdjustWindowRect(&rect, style, ::IsMenu(::GetMenu(pParent->GetSafeHwnd())));
ModifyStyleEx(WS_EX_CLIENTEDGE, 0);
pParent->ModifyStyle(WS_THICKFRAME, WS_DLGFRAME);
pParent->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);
}
void CDemoView::DialogToFormView()
{
CWnd* pParent = GetParent();
CRect rect;
GetTotalClientRect(&rect);
DWORD style = pParent->GetStyle() & ~WS_DLGFRAME | WS_THICKFRAME|WS_CAPTION;
::AdjustWindowRectEx(&rect, style, ::IsMenu(::GetMenu(pParent->GetSafeHwnd())),
WS_EX_CLIENTEDGE);
ModifyStyleEx(0, WS_EX_CLIENTEDGE);
pParent->ModifyStyle(WS_DLGFRAME, WS_THICKFRAME|WS_CAPTION);
pParent->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);
}
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Ahhh, I knew someone would post the right way to do it.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
Always happy to help.
Thanks John!
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
Christian, your last message was
>>The thing you have to consider is, what do you want to achieve ? The way
>>you're writing the file, you're getting an 8 bit greyscale image, if you
>>put this info into an 8 bit bitmap with a palette that went evenly from
>>0,0,0 to 255,255,255, it would work. You're only writing out one colour
>>value as far as I can see, and you're now correctly calculating the grey
>>value. Therefore making your bitmap 8 or 16 bit internally will only result
>>in messy calculations to get to the same point you're reaching now. Please
>>correct me, but I believe you're writing out one unsigned char per colour,
>>although you're making the variable an unsigned long, it will still be
>>between 0 and 255, yes ?
Yes, it still between 0...255.
And more, i compared it for 24 and 32 bpp with using GetPixel function
BYTE grayValue = (BYTE)(int)((GetRValue(clr) + GetGValue(clr) + GetBValue(clr)) / 3),
and it was the same.
But for 8 bitmap, then i using GetPixel it was like
125 125 125 (Red Green Blue)
and for my code it was
31 31 31
Why? I don't know
Yes, i need grayValue for every pixel
But i don't neen GetPixel(), because it work with handle (hDC, DC and other),
i need information only from bitmap (avi frame->LPBITMAPINFOHEADER)
But i haven't ideas how to wrote simple code for 8 and 16 bpp
|
|
|
|
|
So you're storing the bitmaps as *well* and therefore want to be able to read them regardless of format ? GetPixel() will work, albeit slowly. I'm about to go to work, but I'll dig up some code from my paint program tonight to get the info you need in order to convert 8 and 16 bit values into an RGB value.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Thanks a lot, Christian!
My email mrserg@aha.ru or mrserega@aha.ru
|
|
|
|
|
|
Hello!
I'd like to know how do I add a popup menu in a CTreeCtrl
TY
|
|
|
|
|
|
- The following statements are taken from MSDN(Ti: LoadLibrary)
The Visual C++ compiler supports a syntax that enables you to declare thread-local variables: _declspec(thread). If you use this syntax in a DLL, you will not be able to load the DLL explicitly using LoadLibrary or LoadLibraryEx. If your DLL will be loaded explicitly, you must use the thread local storage functions instead of _declspec(thread).
- I do not understand what means "explicitly" here? Why should we use thread local storage functions other than thread-local variables?
- Can you help?
Thanks,
Maer
|
|
|
|
|
'Explicit' loading means that your app uses LoadLibrary[Ex] to bring a DLL into process adress space at some point of execution. You have to get the address of exported procedure[s] later with a call to GetProcAddress.
OTOH, 'implicit' loading (for which __declspec(thread) works correctly) means that system loader will load .dll automatically at the program startup --and-- it will resolve references to exported functions. You just need to link with import library to make this happen. No LoadLibrary, no GetProcAddress.
Now, the __declspec(thread) problem - there's some magic going on during the program startup. The C Runtime creates some thread-local storage space and puts the variables marked as __declspec(thread) there. This happens when all implicitly loaded .dlls are already in place. If you load .dll explicitly later with __declspec(thread) variables, there may be no space left - the C runtime doesn't know you've loaded some .dll. In such case, you have to use TlsXXX functions provided by Windows 'manually'.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- The TLS is the local storage of a thread. Suppose a thread loads a Dll. Then the Dll will initialize the TLS.
- I think the TLS belongs to thread and not belongs to Dll. So I do not understand why should Dll do the initialization task.
- Since the TLS belongs to thread, I think it is the job of thread to do the initialization of the TLS.
- Can you help?
Thank,
Maer
|
|
|
|
|
Well, the thread is doing the initialization of it's TLS. And it is doing it by executing the code contained in the DLL. Remember, the code in the DLL (or in any other place in your program, for that matter) can be executed by any thread in your program - you cannot say that any code belongs to any specific thread. The key term here is that the code is executed in the context of a thread. The same code can be executed in the context of different threads - it can even be executed simultaneously, leading to multithreading issues if you don't protect your data structures. And using TLS is one way of separating thread-specific data from the rest.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
bla
Don't open your mouth, unless you have to say something.
|
|
|
|
|
|
Hello, the codegurus around the world.;)
Even though I can't explain that the class derived from CView will not
deal with WM_TIMER message correctly, I have the same experience of yours.
SetTimer didn't work on the class derived from CView.
One reason may be that CView isn't always exist in the frame on SDI and MDI.
Another reason may be that CView have the different message stream.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I have just tested it on my system, at it works without problems! I set a timer in OnInitialUpdate and handle it in OnTimer (where it's also killed).
void CTest2View::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_iTimer = SetTimer(1, 1000, NULL);
}
void CTest2View::OnTimer(UINT nIDEvent)
{
KillTimer(m_iTimer);
AfxMessageBox("Timer received");
CView::OnTimer(nIDEvent);
}
Running the app gives me a "Timer received" message box after 1 second.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Sorry, Masaaki - the timers work with CView-derived classes. I have two such timers in the project I'm currently working on. CView uses the same message queue - it's just a normal HWND.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hey
i need to multiply 2 LONGs to a LONGLONG (64-bit width integer), without it overflowing.
I've heard the Mul64 function does this, but what header(s) do i need to include for this.
Please respond quickly!!
Paul
|
|
|
|
|