|
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
|
|
|
|
|
It's almost an option, but notentirely: this way, the cursor appears, and I don't like any cursors around. Also, disabling the edit control gets me almost there, but the text is grayed and I want it black (do you know how to change this?).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
this way, the cursor appears, and I don't like any cursors around
You mean the insertion point cursor, right? So maybe handling WM_SETCURSOR will get rid of this problem?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
I tried, and it doesn't seem to work (the docs says one should return TRUE from the parent to stop further processing to the childs). Anyway, I guess this has to do with the mouse rather than the text cursor.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
the docs says one should return TRUE from the parent to stop further processing to the c
So you handled WM_SETCURSOR in parent right? Maybe you should add handler in edit clas, do not call base class implementation and just set cursor to standard arrow instead?
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Have just tried it, returning TRUE and FALSE --nothing. I guess this message has nothing to do with text cursors, but rather it is suposed to handle mouse icons and stuff.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Wait - what do you mean by 'text cursor'? A caret? This blinking | thing? In this case, you'd have to probably handle WM_SETFOCUS (or EN_SETFOCUS) and call HideCaret.
Tomasz Sowinski -- http://www.shooltz.com
To some its a six-pack, to me it's a support group
|
|
|
|
|
Yes, I refer to the | blinking thing. I've finally found a solution: it doesn't involve handling those messages, but rather cheating the system with the enabling/disabling thing by handling WM_ENABLE . I found this trick here[^].
Thank you very much for your efforts. Keep the good work helping people here at CP!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm not to sure there is a way to do this easily, Basically within my OnWizNext I validate data, if this fails, I want to drop out of the wizard process for the user to modify data. I was hoping to be able to call OnCancel() however this doesnt work, has anyone any ideas?
|
|
|
|
|
Popup a messagebox, tell some data error and return without call base class
overload function "OnWizNext"
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|