|
Thanks Pavel,
That'll work great. My next question is how to map commands to the dynamically added menu items?
Josh Knox
We will rid the world of buttmunching pussnuts. Armed only with my blunt spoon of death and my circumcising potato peeler. Death and torture to them all. - Michael Martin
|
|
|
|
|
Sorry I can't help you, but I had the same problem.
I dynamically create a menu that contain a certain number of IP adresses, like :
_TRAYMENU_
192.168.0.1
62.43.12.10
etc...
and I want to copy the IP to the clipboard when I click on it (I know for the clipborad, but I don't know how to map commands...)
Thanks!
|
|
|
|
|
Look up the DYNAMENU sample in MSDN. It details how to do this stuff.
Josh Knox
We will rid the world of buttmunching pussnuts. Armed only with my blunt spoon of death and my circumcising potato peeler. Death and torture to them all. - Michael Martin
|
|
|
|
|
Add an ON_COMMAND or ON_COMMAND_RANGE macros to the message map section of the class where you want to catch them:
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_DLLTEST, OnViewDlltest)
... and other macros added by class wizard
ON_COMMAND(ID_xxxx, OnXxxx)
END_MESSAGE_MAP()
You also need to add the void OnXxxx() method to your class.
Pavel
Sonork 100.15206
|
|
|
|
|
Hello everybody:
I want a function to be exectured when I press CTRL + Click over a bitmap image in a Dialog. I know how to do that when I to a Ctrl + Click over the Dialog itself using the OnLButtonDown() function. What do I need to do to make it happen by just clicking the bitmap image? Any answer is more than welcome.
Regards,
Luis E. Cuadrado
)
|
|
|
|
|
Place the bitmap in a static text control on your dialog. Give the control a unique ID and set the notify style for it. You can then write a handler for BN_CLICKED for the static control and check to see whether the control key is pressed (GetKeyState(VK_LCONTROL) || GetKeyState(VK_RCONTROL))
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
Hello:
I tried what you told me and this is what I put in my code:
void CMyClass::OnPicClicked() <br />
{<br />
<br />
if ((GetKeyState(VK_LCONTROL) || GetKeyState(VK_RCONTROL)))<br />
{<br />
}<br />
}
Does that looks correct? I run my application and it doesn't work.
Thank you for your reply.
Regards,
Luis E. Cuadrado
)
|
|
|
|
|
In my previous post I told you that I didn't work. I take that back. It works. I forgot to set the notify style for the CStatic. Works perfect. Thank you very much.
Regards,
Luis E. Cuadrado
)
|
|
|
|
|
Filedownload event is not caugth or not thrown.
I cannot catch it.
Anyone knows the solution????
Thanks
|
|
|
|
|
hio!
i have a split view that i am using, and whenever i replace any view i set the documents title.. the problem is that when i click inside of a field in any of these views the title somehow gets set to the filename of the document (which i beleive is the default of CDocument::SetTitle )
any suggestions? here is an example of how im setting the title:
void CMainFrame::ShowHeader()
{
CView* pView = GetActiveView();
CMyDoc* pDoc = (CMyDoc*)(pView->GetDocument());
m_wndSplitter.ReplaceView(0,0,RUNTIME_CLASS(CHeaderView),CSize(500,HEADERHEIGHT), pDoc);
SetDocTitle(pDoc, pDoc->m_pComp, pDoc->m_pLoc);
m_wndSplitter.LockBar(false);
}
the SetDocTitle() just calls the document's set title function with it formatted the way i want it to look..
-dz
|
|
|
|
|
Hi,
Iam using CDhtmlDialog class.
How can I trap newWindow ?.
Iwant open the new window using my own browser dialog not the IE browser.
Thanks
|
|
|
|
|
I have a COM dll and I am using the libs from Office 2000. When the user hits a button, I open Word. When I open word, sometimes there is text that the user wants to edit so I put the text in a file, then put this filename in the CreateProcess function call so that Word will open this file. But I am having on irritating issue. Every time I do this with Office 2000, I keep getting the messagebox "Do you want to revert to the saved document" right when Word opens. I have tried several things and nothing seems to work so that this message box doesn't appear and Word just goes ahead and opens the file like I want it to. Does anyone have any idea how I can stop this messagebox, do you think there is something wrong with the way I am opening Word, or perhaps is there something wrong with the way I am saving the word document??????
|
|
|
|
|
I have a bitmap resource in my MFC MDI app. I want to show the bmp in my third party image control which takes a pointer to the bitmap (header and all). How do I get a hold of the pointer to the bmp from the resource?
Thanks,
ns
|
|
|
|
|
ns wrote:
I want to show the bmp in my third party image control which takes a pointer to the bitmap (header and all).
You mean the BITMAPINFOHEADER? Then use LoadImage with LR_CREATEDIBSECTION flag.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
The image control expects a pointer to the start of the image: It gets it from disk with stuff like:
pFile = fopen(strFile, "rb");
if(pFile == 0)
{
return 0;
}
fseek(pFile, 0, SEEK_END);
int fileSize = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
if(pImage ==NULL) return fileSize;
fread(<code>pImage</code>, fileSize, 1, pFile);
pImage[fileSize] = 0;
fclose(pFile);
What I want to extract from the bitmap resource is the pImage
Thanks so much,
ns
|
|
|
|
|
So you'll need extra BITMAPFILEHEADER before DIB section. Sooner or later your image control will need a handle to DIB or DDB. Are you absolutely sure your control only loads .bmp files?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
No, it takes jpegs and tiffs too but it uses the same strategy (fread) and processes the pre-DIB section information in itself. But I have a bmp to deal with. I've not read up on DIB, DDB etc, and am learning as I go along. So I guess (sorry if I'm being unbelievably dense), what I want is somehow to get the pImage out from the resource. Is there something like:
char* pImage = Somefunction(IDB_BMP1);
Any links would be great. Meanwhile I'm hurrying along with my background reading. I did find how to get (I hope it works) to get at the colortable:
HGlobal pBMP = ::LoadResource(NULL, ::FindResource(NULL, MAKEINTRESOURCE(ID), RT_BITMAP));
PBITMAPINFO pBMInfo = (PBITMAPINFO) (pBMP + sizeof(BITMAPFILEHEADER));
int bitCount = 8;
int clrUsed = 0;
if (pBMInfo->bmiHeader.biBitCount != bitCount ||
pBMInfo->bmiHeader.biClrUsed != clrUsed )
return;
memcpy(pPalette, pBMInfo->bmiColors, (4*clrUsed));
I havent tried it out yet. Surely this pBMP is not what I'm looking for? I need a char* back, and not sure what to do with an HGlobal.
|
|
|
|
|
The code you've posted isn't correct. The bitmaps stored as resource doesn't have BITMAPFILEHEADER structure; they start with BITMAPINFOHEADER.
You'll have to create a memory buffer and copy BITMAPFILEHEADER followed by stuff loaded with LoadResource call.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Okay. Thanks. A little digression. I removed the offset for the fileheader and tried to access the color table like this: but no luck!
char* pBMP = (char*) ::LoadResource(NULL, ::FindResource(NULL, MAKEINTRESOURCE(IDB_BITMAP1), RT_BITMAP));
PBITMAPINFO pBMInfo = (PBITMAPINFO) (pBMP );
int bitCount = 8;
int clrUsed = 0;
if (pBMInfo->bmiHeader.biBitCount != bitCount ||
pBMInfo->bmiHeader.biClrUsed != clrUsed )
return;
memcpy(pPalette, pBMInfo->bmiColors, (4*clrUsed));
What am I doing wrong? THanks for all this help!
|
|
|
|
|
clrUsed is zero. 4 * clrUsed is zero as well.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Yikes. I needed to bitshift it to 256. Many thanks. It looks good now. A big problem resolved!
ns
|
|
|
|
|
How do you execute the MapNetwork drive wizard? (and disconnect drive)
Is there any other method than trying to simulate a context menu command on MyComputer?
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
BOOL CAMIDoc::MountNetworkDrive()<br />
{<br />
CString sDrive;<br />
<br />
BeginWaitCursor();<br />
while (TRUE)<br />
{<br />
if( (_access( "\\\\apps1\\data", 0 )) == -1 )<br />
{<br />
CDriveMountDlg dlg;
int response = dlg.DoModal();<br />
if (response == IDCANCEL)<br />
return FALSE;<br />
<br />
NETRESOURCE resource;<br />
resource.dwType = RESOURCETYPE_ANY;<br />
resource.lpRemoteName = "\\\\apps1\\data";<br />
resource.lpProvider = NULL;<br />
<br />
int nDrive = 4;<br />
<br />
sDrive.Format("%c:", nDrive + 'A');<br />
resource.lpLocalName = sDrive.GetBuffer(2);<br />
<br />
DWORD result = WNetAddConnection2(&resource, (LPCSTR)dlg.m_sPassword, NULL, 0);<br />
if (result == ERROR_INVALID_PASSWORD)<br />
{<br />
AfxMessageBox("Invalid password. Aborting");<br />
return FALSE;<br />
}<br />
<br />
while ((result != 0) && (nDrive < 25))<br />
{<br />
nDrive++;<br />
sDrive.Format("%c:", nDrive + 'A');<br />
result = WNetAddConnection2(&resource, (LPCSTR)dlg.m_sPassword, NULL, 0);<br />
}<br />
<br />
if (result != 0)<br />
{<br />
AfxMessageBox("Unable to mount a drive. Please check password and ensure you have a free drive letter. Aborting.");<br />
}<br />
else<br />
{<br />
m_sDrive = sDrive;<br />
m_bMountFlag = TRUE;<br />
break;<br />
}<br />
}<br />
else<br />
break;<br />
}<br />
<br />
EndWaitCursor();<br />
return TRUE;<br />
}<br />
<br />
BOOL CAMIDoc::DismountNetworkDrive()<br />
{<br />
if (m_bMountFlag)<br />
{<br />
DWORD result = WNetCancelConnection2(m_sDrive, 0, TRUE);<br />
if (result != NO_ERROR)<br />
{<br />
result = GetLastError();<br />
if (result == ERROR_BAD_PROFILE)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
else if (result == ERROR_CANNOT_OPEN_PROFILE)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
else if (result == ERROR_DEVICE_IN_USE)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
else if (result == ERROR_EXTENDED_ERROR)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
else if (result == ERROR_NOT_CONNECTED)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
else if (result == ERROR_OPEN_FILES)<br />
{<br />
m_bMountFlag = FALSE;<br />
}<br />
return FALSE;<br />
}<br />
}<br />
return TRUE;<br />
<br />
}
|
|
|
|
|
I've got a CStatic with more text than gets into the window, and would like to make the text scroll programmatically. CEdit s do have LineScroll which do precisely what I want, but alas this method is not available for static controls. Does anyone know some custom-made routine or anything to achieve this behavior? The thing can be replicated with CWnd::SCrollWindow and all that stuff, but details are clumsy and maybe someone has already done the work
Thanx
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Is read-only edit control an option?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|