|
yes,it is change desktop bkcolor
|
|
|
|
|
Hi,
I am automating Word 2000 and I want to disable the "Ctrl C" keyboard functionality. (Using VBA I am successful in disabling the "Ctrl+C" by doing this - "Application.FindKey(BuildKeyCode(wdKeyControl, wdKeyC)).Disable")
I am using the following C++ automation code which gives me the DISP_E_EXCEPTION error code on IDispatch::Invoke for "Disable" method ("AutoWrap" function below is a wrapper around IDispatch::Invoke). Here is my C++ code:
parm1.vt = VT_I4;
parm1.lVal = wdKeyControl;
parm2.vt = VT_I4;
parm2.lVal = wdKeyC;
VariantClear(&result);
AutoWrap(DISPATCH_METHOD, &result, pWdApp, L"BuildKeyCode",2,parm2,parm1);
parm1.vt = VT_I4;
parm1.lVal = result.lVal;
VariantClear(&result);
AutoWrap(DISPATCH_PROPERTYGET , &result, pWdApp, L"FindKey", 1,parm1);
pWdKey = result.pdispVal;
AutoWrap(DISPATCH_METHOD, NULL,pWdKey , L"Disable", 0);
Error :
"This method or property is not available because this document is in another application"
I will appreciate any help on this.
Thanks.
Vishal
----------------------
Vishal More
|
|
|
|
|
Is there any good article about this? Thank you
|
|
|
|
|
|
Hi
Problem is like this on my Mousemove event i am checking whether some text is under the mouse or not. If text is under then i will mark the flag to true.
Based on this i am shoing my popup menu say if m_textunder == true then Show pop up menu item Edit TEXT , else show ADD TEXT menu item.
Problem what i am facing is if i mouse move over the text my flag get set to true and EDIT TEXT items get show, now if i right click over other portion of the view where test is not under then still it is showing the EDIT TEXT OPTION. Only in case that if i left click over the area then it will refresh i.e. again start to show the ADD TEXT if text is not under.
My code portion is as per follows:
Function onMouseMove:
CTextLabel *pTxt = pDoc->GetCurrentTextLabel (point,m_Scale,1);<br />
if(pTxt != NULL)<br />
{<br />
m_TextUnder = true;<br />
m_TextToEdit = pTxt->GetText ();<br />
}<br />
else<br />
{<br />
if(m_TextUnder)<br />
AfxMessageBox("not under");<br />
m_TextUnder = false;<br />
}<br />
}<br />
<br />
Function -->OnRButtonDown(UINT nFlags, CPoint point) <br />
<br />
CNewMenu menu;<br />
menu.CreatePopupMenu();<br />
menu.InsertMenu(0, MF_BYPOSITION, ID_VIEW_ZOOMIN,"Zoom In");<br />
menu.InsertMenu(1, MF_BYPOSITION, ID_VIEW_ZOOMOUT,"Zoom Out");<br />
menu.InsertMenu(2, MF_BYPOSITION, ID_VIEW_SPECIFYZOOM,"Specify Zoom");<br />
<br />
if(m_TextUnder)<br />
{<br />
menu.InsertMenu(3, MF_BYPOSITION, ID_SEPARATOR, "");<br />
menu.InsertMenu(4, MF_BYPOSITION, ID_EDITTEXTLABEL, "Edit Text Label");<br />
}<br />
else<br />
{<br />
menu.InsertMenu(3, MF_BYPOSITION, ID_SEPARATOR, "");<br />
menu.InsertMenu(4, MF_BYPOSITION, ID_OPT_TEXT_LABEL, "Add Text Label");<br />
}<br />
ClientDC.LPtoDP(&point);<br />
ClientToScreen(&point);<br />
menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this);
What can be the wrong ?
|
|
|
|
|
What are you trying to do? Change context menu items dependent on where the mouse pointer is?
While TrackPopupMenu is running, it has mouse capture. That is, all mouse messages go to the menu, even if the mouse isn't over it. You can't change the contents of a popup when it's displayed, anyway, because TrackPopupMenu runs a modal loop (i.e. it doesn't return until the user either chooses a menu item or clicks away from it).
The user also won't expect this to change while they have a popup menu item. Normally the contents of a context menu reflect the currently selected item in the document at the time the menu was selected.
I suggest working out which menu items to show in the button click handler. Also, for consistency with Microsoft applications and the Windows shell, the context menu should be shown on button UP, not button down (try it on Explorer).
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
In a non-MFC application I used the fread() function in order to read documents (WORD) EXCEL files and PowerPoint files.
The problem is that I get not only the content of those files but also information about the file (like file owner etc.).
Is there a way to read only the content of those files?
|
|
|
|
|
I didn't quite understand your question. Could you please rephrase it?
Though by look of it you're expecting from fread to understand format of excel and word files. If so, your expectations are wrong. It's low level i/o function and knows nothing about file format, it simply read/write bytes.
|
|
|
|
|
didn't expect fread to do nothing but reading
my question is how can i analyze the file format so i can draw from it the content of the file.
thanx
|
|
|
|
|
Well, you obviously have to know file format for that.
I can give you a small hint. Read 2 bytes on offset 0x200. If you have 0x0009, 0x0209, 0x0409, 0x0809 it's Excel file. I don't have much data on PowerPoint format therefore my assumption can be wrong. Nevertheless, if you have 0xA046 there, it's PowerPoint XP(and 2003?). If you have 0xFDFF there, you have to read extra 2 bytes from 0x204 and if you have 0x5eca there, it's PP95 and if the value is 0x5dca, it's PP97(-2002?).
Hope it'll help.
|
|
|
|
|
Are you against using Excel Automation? Trying to use fread() to weed through a .xls file would be no small undertaking.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I derived a template class from a treelist control class,and placed it in a MFC project.In a dialog, using it as : "CTreeCtrl<cif> m_ctrlTree;".But have a lot of fatal error:fatal error C1001: inner compile error.Refering place is executing the member function of template class.What is wrong with that.Pls help me.
|
|
|
|
|
Internal Compiler Error means you've found a bug in the compiler. Typically this means that it doesn't understand your syntax, or you've exceeded a limit. I suggest starting by commenting out the line on which it fails, repeating until you get it to compile. Then uncomment lines until it stops compiling. By repeating, you should be able to narrow down the location of the fault.
You'll also find the KB article C1001 Compiler Error Message - Suggestions for Troubleshooting[^] helpful.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hai....how can i use C++ to save tiff image to raw data>?
|
|
|
|
|
Look at cxImage library in Codeproject
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Maybe a simple question but when you open a database (SQL2000) in MFC CRecordset in mode dymanic and then sort the database by any column(s), why does the database (recordset) become "READ ONLY". It's open for read/write but as soon as you start sorting the database, you can't write/update anymore.
I am trying a workaround with stored procedures but if that fails, I will have to give the sorts.
Anybody out there can help me?
Thanks,
craig christensen
|
|
|
|
|
HI,
How can i manipulate Registry.
Any sample by Example.
thanx
|
|
|
|
|
Check the following sample function for creating & setting a registry key.
You can use APIs RegOpenKeyEx, RegQueryMultipleValues, RegQueryValue defined in winreg.h to read the values from registry keys
BOOL CFTPDlg::RegisterFTPProfile(FTPProfile LocalCopyFTPProfile)
{
BOOL bRetVal;
HKEY hkResult;
CString strTmp;
unsigned char *lpBuf;
int n;
//Preapre the complete Path Name for selected profile.
strTmp = g_strProfileRegPath + CString("\\");
strTmp += (LPCTSTR)LocalCopyFTPProfile.strProfileName ;
bRetVal=RegCreateKeyEx(HKEY_LOCAL_MACHINE,
(LPCTSTR)strTmp,
NULL,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hkResult,
NULL);
if (bRetVal==ERROR_SUCCESS)
{
n=LocalCopyFTPProfile.strHostAdd.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strHostAdd);
bRetVal=RegSetValueEx(hkResult,
"HOST_ADD",
NULL,
REG_SZ,
lpBuf,
n);
free((void *)lpBuf);
n=LocalCopyFTPProfile.strLoginID.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strLoginID);
bRetVal=RegSetValueEx(hkResult,
"LOGINID",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strPassword.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf, (LPCTSTR)LocalCopyFTPProfile.strPassword);
bRetVal=RegSetValueEx(hkResult,
"PASSWORD",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strHostPath.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)LocalCopyFTPProfile.strHostPath);
bRetVal=RegSetValueEx(hkResult,
"HOST_PATH",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strLocalPath.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strLocalPath);
bRetVal=RegSetValueEx(hkResult,
"LOCAL_PATH",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strSleepTime.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strSleepTime);
bRetVal=RegSetValueEx(hkResult,
"SLEEP_TIME",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
n=LocalCopyFTPProfile.strDescription.GetLength()+1;
lpBuf = (unsigned char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf , (LPCTSTR)LocalCopyFTPProfile.strDescription);
bRetVal=RegSetValueEx(hkResult,
"DESCRIPTION",
NULL,
REG_SZ,
lpBuf,
n);
free(lpBuf);
RegCloseKey(hkResult);
return TRUE;
}
return FALSE;
}
|
|
|
|
|
THe following Code giving the Error
that is failing to Open the Key .. n givign mine message box written in else portion..
Keys e created in registry using ur above reply example code
plz help abut open n Query the keys
BOOL bRetVal;
HKEY hkResult;
CString strTmp = "Software\\NDT";
char *lpBuf;
int n;
bRetVal=RegOpenKeyEx( HKEY_LOCAL_MACHINE ,
(LPCTSTR)strTmp,0,0,&hkResult);
if (bRetVal==ERROR_SUCCESS)
{
CString id = "UserName";
n=id.GetLength()+1;
lpBuf = (char *)calloc(n, sizeof(char));
strcpy((char *)lpBuf,(LPCTSTR)id);
LPSTR str;
long j;
bRetVal= RegQueryValue(hkResult, lpBuf, str , &j);
if (bRetVal==ERROR_SUCCESS)
{
AfxMessageBox (" Success");
}
else
{
AfxMessageBox (" Not read the key");
}
}
else
{
AfxMessageBox (" Not open the key");
}
|
|
|
|
|
Check the help documentation for API RegOpenKeyEx. You need to specify the access level you desire while opening a registry key. You haven't given that. (Check the help documentaion for 4 the para of the API RegOpenKeyEx)
That will solve your problem;)
|
|
|
|
|
there`s plenty of good article here. But I forgot where , may be you can find it at system
|
|
|
|
|
Hi,all
In an application I currently involved in. when user enter some data, the app will send the data to specified mailbox. we want the app send mail without any user interactive (user may need to enter his/her email address when install the app)
I had try MAPI, but it is proven that MAPI need a MAPI Client (eg. Outlook) be installed and configured before it can work. in the real world, we can't assurance that every PC can fit this requirement.
I had also try some raw socket code to send mail via smtp server, but eventually i found most SMTP server need user authentication. we don't want user enter such info as it is too advance
so i need help.
|
|
|
|
|
>> send mail without smtp server?
That might be like trying to breath without air
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
ispring wrote:
how to send mail without smtp server?
Write it on a piece of paper, place it in an envelope, address it, put a stamp on it, and put it in a mailbox
Humour aside...
If you really can't use MAPI, then you'll need to use raw sockets and connect directly to the SMTP server which holds the recipient's account. You shouldn't need to authenticate yourself to a particular server if you are sending mail to a user whose account is on that server.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan, thank you for you reply.
I have tryed your approach, that is, connect to the target smtp server directly, but the server require user authentication too. so it doesn't work.
it seem that the only way to send email without smtp server is implement a smtp server in my app.
|
|
|
|
|