|
Hi there,
I'm a bit new to C++, been doing Java for a while now and I was just wondering if there is a way to get the 'Start Button' to appear as an entry in the context menu that appears when you right click on the desktop, if not any suggestions on how I should go about it?
Cheers,
/P/
|
|
|
|
|
First of all, i consider u r familiar with the VC++ IDE.
So, first of all, add a "Resource Script" to ur project. Then insert an MENU into it. Add a few feilds to the menu and give it a "DENTIFIER STRING".
Then to display a CONTEXT MENU u hav 2 write:
IN MFC:
void CMenuTestView::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu myMenu;
CMenu *ptrMenu;
myMenu.LoadMenu(IDR_MYMENU);
ptrMenu=myMenu.GetSubMenu(0);
ClientToScreen(&point);
ptrMenu->TrackPopupMenu
(
TPM_LEFTALIGN|TPM_RIGHTBUTTON,
point.x,
point.y,
this,
NULL
);
CView::OnRButtonDown(nFlags, point);
}
IN WINDOWS API:
case WM_RBUTTONDOWN:
POINT p;
GetCursorPos(&p);
TrackPopupMenu(GetSubMenu(LoadMenu(gloInst,"MYMENU"),0),
TPM_LEFTALIGN | TPM_LEFTBUTTON,p.x,p.y,0,hwnd,NULL);
break;
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
|
Hi!,
I want to create a read-only view of excel,word or powerpoint file using the ole techonology.
I use the default object handler provided in ole32.dll
I dont know what steps to follow after creating the object using:
hr=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_HANDLER,
IID_IUnknown,(PVOID*)&pUkwn);
the object handler basically implements IDataObject,IOleCache and IViewObject.
IViewObject::Draw will draw on the specified device.
but before that I want to pass data to the object.
which interface shall I use?
thanks
Anshuman
|
|
|
|
|
Im getting this error in a project Im working on, its referencing a .cpp file with function definitions, Im using the same .h & .cpp file on their own just using a main.cpp to test it and it works fine, but when I brought it over to the larger project I get this error:
fatal error C1010: unexpected end of file while looking for precompiled header directive.
I checked the MSDN library and it was of absolutly no help whatsoever, I dont know what it even means. Im using VC7 with win2k.
Cheers
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
arf, i've already seen that error, and i've got abslolutely no idea about its cause.
To avoid that, check Your project settings and disable the precompiled headers... it will work.
if anybody know about the reason this error occurs, let us know !!
TOXCCT >>> GEII power
|
|
|
|
|
put #include "stdafx.h" at the top of the file.
Or, go to project->settings and select the file. Go to C++->Precompiled Headers and set it to "Not using precompiled headers"
|
|
|
|
|
Your larger project is setup to use precompiled headers. This allows you to setup a set of include files that are used through-out your project and have them compiled just once. This is normally done by including the required headers in stdafx.h. Then when compiling the project VC++ expects stdafx.h to be included at the start of each .cpp file.
Just add #include "stdafx.h" to the start of the new .cpp file.
|
|
|
|
|
|
Someone asked me this question this morning - and I didn't have an answer. Can anyone explain why it is bad to use a macro function?
Dylan
|
|
|
|
|
because there is no controle on the parameters passed to it. second reason, we are obliged not to separate the macro name and the opening parenthesis '(' that follow it, which is not very practical.
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
we are obliged not to separate the macro name and the opening parenthesis
Only in the macro's definition, not its usage.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
ok sorry, it was confused in my mind... but, that was a bit right anyway
thx for the precision...
TOXCCT >>> GEII power
|
|
|
|
|
|
There is no type checking.
Ant.
|
|
|
|
|
thank you
very useful !
TOXCCT >>> GEII power
|
|
|
|
|
Here is the classic example:
#define tolower(x) (isupper(x)?(x)-32: (x))
*pOut++ = tolower(*pIn++);
What does that expand to?
*pOut++ = (isupper(*pIn++)?(*pIn++)-32: (*pIn++));
Due to the expansion, pIn will be incremented twice. This is a behavior that is totally different from what is expected when tolower is defined as a function.
Here is another example
#define DOADD5(x) x+5
int iOutput = DOADD32(1)*2;
What is the result, 12? Nope, the result is 11.
When you look at the expansion, you get 1+5*2. Do to operator precedence, you get 5*2 then add 1 instead of 1+5 then times 2.
Some of these problems can be avoided, some can not.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Whether it is always bad is a matter of opinion.
Bad things about macros:
1) No direct validation of arguments.
2) Micro expansion could lead to unexpected results.
Examples:
#define MUL(a,b) (a*b) // bad macro
MUL(123-45,678-90) expands to (123-45*678-90) equals -30477
#define MUL2(a,b) ((a)*(b)) // better macro
MUL(123-45,678-90) expands to ((123-45)*(678-90)) equals 45864
Good things about function inlining:
1) Arguments are validated at compile time.
2) There is no expansion of arguments; therefore no misunderstanding of what the result will be.
Example:
inline int Mul(int a, int b) { return a * b; }
Mul(123-45,678-90) equals 45864
INTP
|
|
|
|
|
I use Windows ApiHook hooked the ExtTextOut and Successfully replace theorginal function with MyExtTextOut.
i want replace orginal Text with myText.but after replaced ,there only display some text. for exam :
orginal text="My Computer",(11 char)
after replace by myText="My and Your Computer"(20 char) there only display "My and Your" (11 Char).
How can i display full text.
thank you!
uqtur@163.com
uqtur
|
|
|
|
|
Where can i copy codes from to use in my database?
|
|
|
|
|
the program below ,when i set point(0,0) ,i can see those strings in view ,but when i set point(20,-20) ,those strins only can be seen in File/Print Preview.
void CTestView::OnDraw(CDC* pDC)
{CTestDoc* pDoc = GetDocument();
CString str;
//CPoint point(0,0);
//pDC->TextOut(point.x,point.y,"tanghuitian");
//point+=CSize(20,-20);
str.Format("%6.6s%6.6s%6.6s%6.6s%6.6s","index","left","top","right","bottom");
pDC->TextOut(point.x,point.y,str);
}
|
|
|
|
|
Its the way a window display works. The top left corner is 0,0. So when plotting on your screen display it falls outside the clipping region in use and is not shown. During print preview, no clipping region is in force, and point 0,0 is still in the top left of the page, but at the start of the printable area of the page (i.e. indented by the margin amounts).
Your string at (20, -20) is off the top on screen
but visible in print preview due to the extra canvas and lack of clipping region
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Can somebody post me a link where a UNICODE file is loaded and it's content is displayed on a Dialog? So how to load a UNICODE file ? How to display a UNICODE text on a Dialog?
Thanks
xxx
|
|
|
|
|
I'm sure there was a class on CP that can load Unicode text, try to search. Underneath, the is no easy way to do it - you simply load portion-by-portion, analyzing content. Unicode file can start with signature (FFFE or FEFF) - this will help to to understand what you have. But it is not required - in this case you will have to try to detect if text is unicode (see ::IsTextUnicode()). As for displaying, it depends on your project - if it is Unicode-enabled, then no problems. Otherwise you will need to convert to plain text.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|