|
Hi, i am newbie and want to know :
How can i create a Owner Draw Menu
I did it easily with buttons , choosing Owner Draw property in the properties dialog box. But cant do it with menus
thanx
|
|
|
|
|
|
Hi guys,
i had posted this question two weeks ago but did not get any useful reply that would help me , so sorry for the repeated post
I am writing a simple application similar to Spy++ Utility , that displays different information about chosen window.
I want to draw that black rectangle(like in Spy++) over windows ,when mouse is over that window. I manage to draw it , but when i move mouse to another window the rectangle stays on the previous window and on the new also.
I used to store previous windows and when the mouse was over new window i was simply sending the Invalidate() function to the previous window.
For some strange reasons this worked on 95% of the windows , but there were some areas where the rectangle stayed partialy.
Can anyone suggest me any another way of achieving this??
Best Regards
"Success is the ability of going from one failure to another with no loss of enthusiasm" - W.Churchill
|
|
|
|
|
why don't you knock up a quick app that logs all messages it gets, then use Spy++ on that app, and see what messages spy++ is using to force redraw. Then do that in your app.
out of interest, what will your app do that spy++ doesn't?
using System.Beer;
|
|
|
|
|
Jon Hulatt wrote:
why don't you knock up a quick app that logs all messages it gets, then use Spy++ on that app, and see what messages spy++ is using to force redraw. Then do that in your app.
I haven thought about that i'll try that thanks, but i doubt it uses the same technique as Lim Bio Liong in his article[^], Lim does not redraw the window , he uses Brushes , but i could not implement this in MFC.
So i thought that Invalidate() would help and it does , but as i see i have problems when i move the cursor from a parent window to its child,that's the case when the rectangle partially stays on the parent . But when i move the cursor between Child windows(ex : from button to button,..) it works
Jon Hulatt wrote:
out of interest, what will your app do that spy++ doesn't?
Actually nothing, so far. I decided to do it just for interest
"Success is the ability of going from one failure to another with no loss of enthusiasm" - W.Churchill
|
|
|
|
|
Some tools that draw selection rectangles over other windows have the same problem as yours, and I am seeing this with the ZoomIn enhancement I have been working on.
Typically, they invalidate the entire screen, which causes every piece of every window to redraw.
You might want to see what Jospeh Newcomer has done in his new ZoomIn tool he posted recently to CodeProject.
http://www.codeproject.com/tools/betterzoomin.asp[^]
|
|
|
|
|
I currently developing a program and it is workable, but somehow when i turn on the program for a long time(15 minutes depends on how big the computer memory is) then it will hang. I check out that when i add a component which is inside my program, for example a bitmap file into my program. The computer memory starts to increase rapidly everytime i add a component. I been using meta files to store this added components but i have no idea how to remove the metafiles that is added, can anyone here help me. I'll be really grateful
From: Guibert
|
|
|
|
|
Same problem i faced yesterday and fixed it.
In my case i was creating a DISPLAY DC and one Compatible DC and one Bitmap memory through CreateDIBSection API call.
hdc = CreateDC("DISPLAY",NULL,NULL,NULL);
Bitmap = CreateDIBSection(hdc, pBMI, DIB_RGB_COLORS, (void**)&m_pVideoBits, 0, 0);
HDC hSrcDC = CreateCompatibleDC(hdc);
SelectObject(hSrcDC, m_hViewfinderBitmap);
while Deleting the Bitmap and DC you should follow the following way
DeleteDC(hSrcDC);
DeleteObject(Bitmap);
DeleteDC(hdc);
If your code also have some this kind of thing then please take care that, you should not clean a bitmap untill it is attached to the DC
Hope i could help you some way.
Regards
Anil Kumar
|
|
|
|
|
Can any body tell me why structure alignment is necessary in C/C++ and what it may cause?
Anil Kumar
|
|
|
|
|
Hi
Applications should generally align structure members at addresses that are "natural" for the data type and the processor involved. For example, a 4-byte data member should have an address that is a multiple of four.
This principle is especially important when you write code for porting to multiple processors. A misaligned 4-byte data member, which is on an address that is not a multiple of four, causes a performance penalty with an 80386 processor and a hardware exception with a MIPS® RISC processor. In the latter case, although the system handles the exception, the performance penalty is significantly greater.
/\|-||\/|/\|)
|
|
|
|
|
Or maybe this can help too:
All modern CPUs expect that fundamental types like ints, longs and floats will be stored in memory at addresses that are multiples of their length.
CPUs are optimized for accessing memory aligned in this way.
Some CPUs:
allow unaligned access but at a performance penalty;
trap unaligned accesses to the operating system where they can either be ignored, simulated or reported as errors;
use unaligned addresses as a means of doing special operations during the load or store.
When a C compiler processes a structure declaration, it can:
add extra bytes between the fields to ensure that all fields requiring alignment are properly aligned;
ensure that instances of the structure as a whole are properly aligned. Malloc always returns memory pointers that are aligned for the strictest, fundamental machine type.
The specifications for C/C++ state that the existence and nature of these padding bytes are implementation defined. This means that each CPU/OS/Compiler combination is free to use whatever alignment and padding rules are best for their purposes. Programmers however are not supposed to assume that specific padding and alignment rules will be followed. There are no controls defined within the language for indicating special handling of alignment and padding although many compilers like gcc have non-standard extensions to permit this.
Summary
Structure Alignment
Structure alignment may be defined as the choice of rules which determine when and where padding is inserted together with the optimizations which the compiler is able to effect in generated code.
/\|-||\/|/\|)
|
|
|
|
|
But as per my understanding the structure members are stored in the contigous memory locations for example
struct temp
{
char a,
int b,
float c,
};
if i declare temp *structPtr = 0x00000000 (Address of element a)
then what should be the address of element b if it is 0x00000002 then one byte is waisted.
According to you b should have address of multiple of 4.
So i can say that there is a trade of CPU performance vs Memory usage
Am i right please guide me.
Regards
Anil Kumar
|
|
|
|
|
Yes, memory usage versus performance.
In Visual Studio you can use the #pragma pack() to control memory alignment on a structure-by-structure basis.
|
|
|
|
|
Generally the default structure alignment (which you should use unless there is a compelling reason not to) is 8 bytes. This aligns all basic data types (up to doubles) to even multiples of their size.
Example (using 8 byte alignment):
struct test
{
char a;
int b;
WORD c;
char d;
double e;
};
The offset addresses are:
a = 0
b = 4
c = 8
d = 10
e = 16
Total size of the structure: 24 bytes
Notice there is some wasted space in there. You can add some variables to this and not increase the size of the structure at all. The following structure is still 24 bytes in size, but is now fully packed.
struct test2
{
char a;
char a2;
WORD a3;
int b;
WORD c;
char d;
char d2;
int d3;
double e;
};
|
|
|
|
|
Respected All
Regards!
I have a CString object which has a value like
----------------------------------------
CString str=ss.find(0,4) //from this statment the str will be assign to
//file name ;
and now this "str" is a File name which i have to use in fileopen like
pFile=open("C:\\str.dat","r");
but it cant open str.dat as in the above satatment.now i think that i have to assign it to another string type variable and then can use it in opening a file.
but how i do it,,plz help me.
waiting for + response.
david
david
|
|
|
|
|
i'm not sure i understand well, but what about this ?
pFile=open("C:\\" + str + ".dat","r");
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
convert to char*
CString ss;//=xyz, david
char* str = ss.GetBuffer(cs.GetLength());
then construct ur file name.. with strcat(str,"//..dat"), so u wont get confused
then
pFile=fopen(str,"r");
am i right?
V
|
|
|
|
|
Hello,
I want to close all open Windows in my Application (not the MainWindow).
Unfortunately this Code fragment does not what I'm expecting
Here is my Code:
//Test Only for 4 Windows
CWnd * pWnd = NULL;
pWnd = GetActiveWindow();
for(int i = 1; i < 4; i++)
{
pWnd = GetActiveWindow(); //I tried GetNextWindow too
if (pWnd != theApp.GetMainWnd())
{
pWnd->PostMessage(WM_KEYDOWN,VK_ESCAPE);
}
pWnd = NULL;
}
Thanks fpr your Help.
And greetings from Germany
|
|
|
|
|
I have it!!
The Solution:
CWnd * pWnd = NULL;
pWnd = GetActiveWindow();
while(pWnd != theApp.GetMainWnd())
{
((CDialog*)pWnd)->EndDialog(IDCANCEL);
pWnd = GetActiveWindow();
}
|
|
|
|
|
You could also try to post the WM_CLOSE message to the windows.
If you notice strange side effects, you could consider doing the WM_CLOSE instead of calling EndDialog directly.
|
|
|
|
|
Sends the WM_CLOSE Message IDCANCEL?
I would really like to use WM_CLOSE but I 'm not sure
if the Windows is closed with IDCANCEL. My solution has a
disadvantage it closes only Modal Dialogs
Daniel
|
|
|
|
|
WM_CLOSE asks the model dialog window to close.
You are correct, the WM_CLOSE does not ensure that they end with the IDCANCEL return value.
The WM_CLOSE will close modeless dialogs as well.
|
|
|
|
|
Hello,
I am working in VC++ 6.0 and Windows Xp Professional.
I created an ActiveX control using MFC ActiveX ControlWizard and have drawn a circle
on the control window using CDC (CView) Class. Now I want to print this circle on the
currently installed printer. I already added a method named "PrintCircle" to
the control. I would like to call this method to do the printing.
Now, my question is, how can I invoke the Printing functions
Meantime I done the job with a SDI Application
I try to do this way...
CMyCtrl
CMyCtrl:: PrintCircle()
{
m_pView->MyPrint();
}
CMyView
CMyView::MyPrint()
{
OnFilePrint();
}
This will goes up to OnpreparePrint () and show the print Dialog too
Then shows an Runtime Error 2147417848(80010108)
Hoping to get a reply soon.
Thanks in advance.
|
|
|
|
|
My company develops Object Orienterd software applications (mainly in VC++).
We have always measured our software quality and complexity using standard
metrics (Line Of Code, MCCabe and so on..). Now we are trying to apply Object
Oriented metrics but we have seen that there are many different approaches,
many different type of metrics an few standardized ways to apply Object
Oriented metrics.
Does someone know something about it ? Which Object Oriented metric can be
used to start ? Are there some articles that can be taken as a guide ?
Thanks a lot!
|
|
|
|
|
Hey All,
Does anyone know how to find what arguments were passed to a process?
I can see that the ProcessViewer from sysinternals can do it, but I can not see how.
ideas?
Jules
|
|
|
|