|
Okay. Thanks.
-----
LRESULT CTestDlg::OnKickIdle(WPARAM, LPARAM)
{
CMenu* pMainMenu = GetMenu();
CCmdUI cmdUI;
for (UINT n = 0; n < pMainMenu->GetMenuItemCount(); ++n)
{
CMenu* pSubMenu = pMainMenu->GetSubMenu(n);
cmdUI.m_nIndexMax = pSubMenu->GetMenuItemCount();
for (UINT i = 0; i < cmdUI.m_nIndexMax;++i)
{
cmdUI.m_nIndex = i;
cmdUI.m_nID = pSubMenu->GetMenuItemID(i);
cmdUI.m_pMenu = pSubMenu;
cmdUI.DoUpdate(this, FALSE);
}
}
return TRUE;
}
-----
The code above is from solution #2 using WM_KICKIDLE. I am not sure what to set to enable and/or disable an item. Does this line do it?
-----
cmdUI.DoUpdate(this, FALSE);
-----
Kuphryn
|
|
|
|
|
And you can use UpdateDialogControls() for updating toolbars and anything that has a ON_COMMAND_UI handler in your dialog.
|
|
|
|
|
You do use ON_COMMAND to handle menu commands in a dialog based app. I'm not sure what you are getting at.
As for disabling menu items, add an OnInitMenuPopup handler similar to this:
void CMyDialog::OnInitMenuPopup(CMenu* pPopupMenu,
UINT nIndex,
BOOL bSysMenu)
{
CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
CCmdUI cmdui;
cmdui.m_pMenu = pPopupMenu;
cmdui.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (cmdui.m_nIndex = 0; cmdui.m_nIndex < cmdui.m_nIndexMax; cmdui.m_nIndex++) {
cmdui.m_nID = pPopupMenu->GetMenuItemID(cmdui.m_nIndex);
if (cmdui.m_nID == 0) continue;
cmdui.DoUpdate(this, FALSE);
}
}
Then you can use the normal ON_UPDATE_COMMAND_UI mechanism to enable/disable your menu items.
|
|
|
|
|
Nice!!! Thanks.
One last question. JohnCz of CodeGuru criticized the use of a dialog based app. He mentioned about using SDI without doc and using a CFormView. What are you inputs on using CFormView? What are the advantagesand disadvantages o using CFormView over a dialog based app and vice versa?
Thanks
Kuphryn
|
|
|
|
|
Using ADO, I want to check and see in a database (its only got one table) what the name of the table is. Any clues or links to this?
Thanks,
ns
|
|
|
|
|
Use ADOX.... You can see the catalog...
Or with ado, you can make a select to the sysobjects catalog.
For example
select name, id, xtype from sysobjects where xtype='u'
regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I just ran into your cadox class on CP....I'm going to try it....
|
|
|
|
|
In you cadox class,
void GetTableName(long nTableIndex, CString strTableName);
if I only have one table what is the index?
Thanks,
ns
|
|
|
|
|
What i would like to do is, that I'm enumerating a list with all the system's different audio compressors. Each time i add a compressor name to the list, i want to set that item's user data to a driver identifier to the compressor. The driver identifier is 4 bytes so it should fit, but when i send the message, it returns LB_ERR. Here's the code:
BOOL WINAPI listCallback(HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport)
{
ACMDRIVERDETAILS details;
int i;
details.cbStruct = sizeof(details);
acmDriverDetails(hadid, &details, NULL);
SendMessage(GetDlgItem(ghWnd, IDC_CODECS), LB_INSERTSTRING, -1, (LPARAM)details.szLongName);
i = SendMessage(GetDlgItem(ghWnd, IDC_CODECS), LB_GETCOUNT, 0, 0) - 1;
SendMessage(GetDlgItem(ghWnd, IDC_CODECS), LB_SETITEMDATA, i, (LPARAM)hadid);
return TRUE;
}
I've also tested if the GetDlgItem(ghWnd, IDC_CODECS) returns a valid handle and it does. And I've also tried replacing the (LPARAM)hadid with, for instance, 2, but it still returns LB_ERR. What am i doing wrong?
Thanks in advance.
-Rune Svendsen
|
|
|
|
|
What happens if you omit the LB_SETITEMDATA part? Do the list items appear (altough without being associated with their respective HACMDRIVERID )? If not, then the problem is somewhere else.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
This is code from an OnEditCopy handler of the Visualization Toolkit. I am trying to add animations to my application by generating the frames (as bitmaps) and then redisplaying them. I have tried using the CPicture class here and the vtk offscreen rendering (using a bitmap writer object), but it is unreliable, crashing the program.
Another solution would be to adapt this code to store the contents. I have never used LPBITMAPINFOHEADER. Can anyone point me in the right direction on how to copy this bitmap data onto the view, thus displaying it? Thanks.
Ted
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
DWORD dwLen; // size of memory block
HANDLE hDIB = NULL; // handle to DIB, temp handle
vtkWindow *vtkWin = pView->GetVTKWindow();
int *size = vtkWin->GetSize();
int dataWidth = ((size[0]*3+3)/4)*4;
dwLen = sizeof(BITMAPINFOHEADER) + dataWidth*size[1];
// allocate memory for the bitmap
hDIB = ::GlobalAlloc(GHND, dwLen);
// setup bitmap info header
lpbi = (LPBITMAPINFOHEADER) ::GlobalLock(hDIB);
lpbi->biSize = sizeof(BITMAPINFOHEADER);
lpbi->biWidth = size[0];
lpbi->biHeight = size[1];
lpbi->biPlanes = 1;
lpbi->biBitCount = 24;
lpbi->biCompression = BI_RGB;
lpbi->biClrUsed = 0;
lpbi->biClrImportant = 0;
lpbi->biSizeImage = dataWidth*size[1];
// start memory rendering
pView->SetupMemoryRendering(size[0],size[1], pView->GetDC()->GetSafeHdc());
vtkWin->Render();
// copy the bitmap data into the bitmap
memcpy((LPSTR)lpbi + lpbi->biSize, pView->GetMemoryData(), dataWidth*size[1]);
::GlobalUnlock(hDIB);
// turn screen rendering back on
pView->ResumeScreenRendering();
// now how can we draw this bitmap on the view (CDC)?
|
|
|
|
|
Ted Christiansen wrote:
now how can we draw this bitmap on the view (CDC)?
use CDC::StretchDIBits
-c
"I am angry that so many of the sons of the powerful and well-placed... managed to wangle slots in Reserve and National Guard units...Of the many tragedies of Vietnam, this raw class discrimination strikes me as the most damaging to the ideal that all Americans are created equal and owe equal allegiance to their country."
--Colin Powell, not talking about his boss
|
|
|
|
|
Chris,
I have tried this and I cant seem to figure out why the memory CDC's are 1x1 pixels.
I added these calls to set the size after I noticed this fact and they are
still 1x1:
CDC *frame = GetDocument()->AddFrame();
ASSERT(frame);
// pic->Load(tmpname);
frame->CreateCompatibleDC(GetDC());
CRect rect;
GetClientRect(&rect);
frame->SetViewportExt(rect.Width(), rect.Height());
frame->SetWindowExt(rect.Width(), rect.Height());
frame->BitBlt(0, 0, rect.Width(), rect.Height(), GetDC(), 0, 0, SRCCOPY);
CSize s = frame->GetWindowExt();
TRACE("CVtksampleView::OnSaveimage window: %d %d viewport: ", s.cx, s.cy);
s = frame->GetViewportExt();
TRACE("%d %d\n", s.cx, s.cy);
What am I missing?
Ted
|
|
|
|
|
Ted Christiansen wrote:
I cant seem to figure out why the memory CDC's are 1x1 pixels
you need to create a compatible bitmap, then select it into your memory DC, before you draw into it. by default, a DC comes with a 1x1 mono biitmap. (also, be sure to use the real dc, not the memory DC, when you make the compatible bitmap, otherwise, you'll get another 1x1).
-c
Argue for your limitations, and sure enough, they're yours.
|
|
|
|
|
I have a CFileDlgST browseforFolder that is spawned at the start of the app. If I do cancel, the app quits:
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
PostQuitMessage(0);
}
BUT
if I already have the app up and running, and then this same CFileDialogST (from CP) pops up to select a browse folder, (it does go into the IDCANCEl condition), but the app doesnt terminate! The dlg vanishes but thats all!
???
I just read that it terminates a thread. I dont have a nmultithreaded app or anything, but would the dialog be considered a thread?
Thanks,
ns
|
|
|
|
|
I tried exit(0) instead and the app crashed! So one function crashes it and one is ignored by the app!!!
The crash only happens if the app is already running (and I didnt cancel out the first time), but then in the next time that same dialog comes upp, and I cancel it crashes! If I cancel out the fisrt time all is well.
|
|
|
|
|
where are you strying to exit from (what class)? I dont call any explicit commands to exit in my program.. however in my InitInstance() of my CMyApp i return false if anything fails to load, etc..
if you are forcing your users to browse when the program opens then do this in your app's InitInstance() function.. then if they hit cancel you can just return FALSE and the app will not continue to load..
hope that helps.
-dz
|
|
|
|
|
I'm in the view class. While the UI is up, at some point they can load a new database, and they browse to it. Thats where if they hit cancel, I want the app to end after asking "do you really want to exit?" etc.
|
|
|
|
|
I'm not sure what your scenario really is, but this sentence should terminate your app, be it dialog-based or SDI/MDI:
AfxGetMainWnd()->PostMessage(WM_CLOSE);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
okay, long story short, newbie - beware.
form someones example of Little Install Builder, we loaded the app in a string and read it looking for a marker, how could i look through the string backwards, looking for a marker? i included the example
CString strTag;
int nLength;
char szModuleName[MAX_PATH];
char *ppMemoryBlock, *ppBlockEnd, *ptr;
char *pStartPos = 0;
// get our own name
GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
LoadFile(szModuleName, &ppMemoryBlock, &ppBlockEnd);
if (!ppMemoryBlock)
{
return FALSE;
}
ptr = ppMemoryBlock;
int nCounter = 0;
strTag = "{35C63374-512F-394a-8516-NE3513160CBG}";
//// reverse it to prevent detecting it in this executable
strTag.MakeReverse();
nLength = strTag.GetLength();
//// search in memory block for string
for ( ; ptr < ppBlockEnd; ptr++)
{
if (nCounter < nLength)
{
// compare part of string
if (*ptr == strTag.GetAt(nCounter))
{
// this part is OK
nCounter++;
}
else
{
// not good -> reset counter
nCounter = 0;
}
}
else
{
// found string !
// // rewind pointer (do not include marker tag)
for (int i=0; i < nLength; i++)
ptr--;
// do what got to do, they extracted file
// // skip marker
for (int j=0; j < nLength; j++)
ptr++;
pStartPos = ptr;
nCounter = 0;
}
}
// // release memory
GlobalFree((HGLOBAL)ppMemoryBlock);
i've tried, looking from ppBlockEnd ptr-- with no luck
any helps really appreciated.
shotgun
|
|
|
|
|
dear freinds,
i want to know that can i make the activex control of my developed mfc based application.
& it is possible to make activex control from exe file.
please help me.....
thanks!
ashutosh agrawal
mail me at:
ashutosh_agrawal78@rediffmail.com
|
|
|
|
|
Hi all,
Is there a way to get notified when the network connection is down or up in VC++?
Thanks
|
|
|
|
|
For Dial-up connections you can use RasConnectionNotification (available in all Windows OSs except 95).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Thanks,
do you know the LAN card link?
|
|
|
|
|
I'm looking for a source code control tool that will let us easily maintain multiple versions. (Go back to a version, fix a bug and get the fixes carried over to the later versions in an automated manner). The idea is we won't need to maintain multiple source bodies. Is such a tool available at all? If so which one is the best? We're using MS Visual SourceSafe 5.0 but it has quite a few bugs and it cannot do most of what we need.
Thanks
|
|
|
|
|