|
You browse the "outline" of the "books". The window to the left tells you where you are and what "book" you are reading. The path element "Platform SDK" should be obvious. From that one you drill down to "Windows Base Services" and somewhere under that you find this functions. I really hope there's no way in h*ll the POS MFC manages to creep into the SDK also.
|
|
|
|
|
I want to pass a handle to an stl container to a windows callback. However, what I'm doing is causing an exception and that's because what I get in the callback isn't the original container. How do I do this correctly?
typedef std::map<int, std::string> MyMap;
BOOL CALLBACK MyCallback(HWND hwnd, LPARAM lParam)
{
MyMap& myMap = reinterpret_cast<MyMap&>(lParam);
// if I change myMap here it goes BOOM!
myMap[0] = std::string("test");
}
void Test()
{
MyMap myMap;
EnumWindows(MyCallback, &map);
}
<b>Todd Smith</b>
|
|
|
|
|
Todd Smith wrote:
MyMap& myMap = reinterpret_cast(lParam);
Try changing that, to this:
MyMap *myMap = reinterpret_cast<MyMap*>(lParam);
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Forget my original post - you proposed what I was about to, but I misread your post altogether
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi.
I am working on a program that displays displays text similar to a text editor. The program works as expected, however, it takes a very long time to display a text file that is 60k or larger.
I am using CEditView as view. Here is the algorithm that displays the texts.
-----
int MAXSIZE = 256;
char text[MAXSIZE];
CEdit &edit = GetEditCtrl();
edit.SetWindowText("first line");
edit.GetLine(0, text, MAXSIZE); // get first line "first line"
CString newText, temp;
temp.Format("%s", text);
newText.Formate("%s%s%s", temp, "\r\n", newText);
...
-----
The concept of the algorithm is this:
1) display first line
2) get first line
3) add first line & new line in a string
4) display string
5) continue until all *new lines* are added
As you can see, this algorithm is extremely impractically. I compared it to Microsoft's Notepade. Notepage *does not* slow done until you open a file that is 1mb or larger.
Is there a better and *faster* way to display multiple lines of text while using the CEditView? Is there a way at all?
Thanks,
Kuphryn
|
|
|
|
|
Why are you allocating memory for each separate string?
Why do you not just load the entire string into one buffer?
You can store newline information in the string.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Each line of text is saved inside of a linked list of CString. If a file contains ten lines of text, then the program would inside ten CString objects inside the linked list. The program can edit text. As the user make changes to a, the program would update the mirror object inside the linked list.
I need a better way to display all the lines inside the linked list.
Kuphryn
|
|
|
|
|
You may want to consider storing the lines of your text in a different type of container besides a linked list. The lookup time for a linked list is O(n). Meaning, if you have n lines in your file, in order to lookup the last line of the text you would have to navigate through n objects.
Consider your 60K file. Say that each line is 100 bytes long. That would give you 600 lines. If you want to get to the string on the 600th line, you will have to navigate through all 600 lines to get to the end and access the last line.
A better choice would be a vector, where lookup is O(1), which means you can access any of the lines with one lookup. Memory allocations may become a problem with a vector. So you could also consider a Map, which its underlying representation is a tree (if you are using STL) and the look up time would be O(log(n)). Which still beats O(n) by a long shot.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks.
You made a very good point. First off, I made a change to the display algorithm. This new algorithm concatenate all lines into one string and then display one string only.
New algorithm:
-----
currentData = pDoc->GetOneLine(pos++);
rE.SetWindowText(currentData);
if (pDoc->GetLineCount() > 1)
{
newData.Format("%s\r\n%s", static_cast<lpctstr>(currentData), pDoc->GetOneLine(pos++));
for (size_t i = 2; i < pDoc->GetLineCount(); ++i)
{
newData += "\r\n";
newData += pDoc->GetOneLine(pos++);
}
rE.SetWindowText(static_cast<lpctstr>(newData));
}
-----
Okay. The reason I chose a linked list was because the program needs to remove one or more nodes at any section of the list. Vector does not have the feature of direct insertion and removal anywhere in the data structure. I have not consider a map. I will definitely consider it now that you have brought it up.
Kuphryn
|
|
|
|
|
I created a class based on CFormView and written a WM_SIZE handler.
When I create form size smaller then Dialog in resourse, controls are resizing correctly, but scrollbars appears...
When I sroll scrollbars there are blank space, and srollable area always have same size as dialog resource...
You can see my problem here: http://www.mediagate.ru/title.gif
any ideas?
Anything that can go wrong will go wrong.
|
|
|
|
|
You can change the size of a form view area. At the end of the OnSize function call
SetScaleToFitSize(cx, cy) ;
This will stop the scroll bars from appearing.
Roger Allen
Sonork 100.10016
yet to be identified being from the planet Paltinmoriumbanfrettybooter
|
|
|
|
|
Thank you for this solution, all works as I need, but sometime, when cy==0 I have Debug Assertion in wingdi.cpp on following line (465):
VERIFY(::SetWindowExtEx(m_hAttribDC, x, y, &size));
I finded this solution:
SIZE csize;
csize.cx=cx;
csize.cy=cy==0?1:cy;
SetScaleToFitSize(csize);
may be there are another ways to correct this problem?
Anything that can go wrong will go wrong.
|
|
|
|
|
Does anyone know how to get a handle to the icon of a running exe?
Thanks
|
|
|
|
|
Are you talking about while your program is running or just get the icon from another application?
If you simply need the icon from another application, you can load the exe of that application into Dev Studio and extract the icon.
If you need the icon while your program is running that will be a little more difficult. What you need to do is get the top level window of that application, and call GetClassInfo . This will give you a WNDCLASS structure that will allow you to get the HICON.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I can't seem to get GetClassInfo to work with an HINSTANCE of an external module. Does this function only work with the HINSTANCE of the current process?
|
|
|
|
|
Hi,
I need to be able to perform screen captures at a high frame rate. So far, I get reasonable performance when I use the BitBlt function to copy the bitmap from the window DC to the memory DC. The problem lies in GetDIBits...this function is incredibly slow and adds considerable bottleneck to the system.
The thing is, I need to be able to use each of the captures in real time. Converting them to DIBs later isn't an option.
Is there a faster option than to use BitBlt/GetDIBits to capture each screen? How about comparing each successive bitmap and using only the deltas...can this be done quickly?
Thanks!
|
|
|
|
|
Yes, copy the screen to a DC that contains a DIBSection - you then have a pointer to the bits at all times.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
The main problem in your slowness extends from the fact that the transfer of the bits from video memory to system memory is very slow. I was able to speed up the screen capture with DirectX, however I was only able to shave off about 200 milliseconds off of a 1.3 second screen capture process.
You are not going to get much faster with the technique that you are using. You may want to look at how NetMeeting does this. They create a second display driver that is able to capture the updates to the screen before they happen, and log the deltas in the bitmap. Then operate only on the deltas.
There is a function that will allow you to detect the rectangle of the changes for a DC, but it only works on memory DCs, and I cannot remember the name of it right now.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Why is it required to place a scope resolution operator when writing code out for class functions, and why does it cause a syntax error?
Loli10
|
|
|
|
|
it's necessary because that's how the compiler knows which class to attach the code to, so to speak. without it, you'd need to have unique names for every function in every class - which makes inheritance pretty much impossible.
-c
Civilization is the limitless multiplication of unnecessary necessities.
Mark Twain
|
|
|
|
|
As Chris has already said, it lets the compiler associate a function's implementation with a class. My point is that you can separate a large class (i.e. one with many functions) into different files. Also (not recommended), the same .cpp file can contain functions of more than one class.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
How must i set the parameters for the function FindFirstFile() if i want to get the shared files which are located at a remote machine!!
I have tried FindFirstFile("\\\\machnine\\*",&data);
and FindFirstFile("\\\\machnine\\",&data); and
FindFirstFile("\\\\machnine",&data);
and much more else but i have always got the error code ERROR_INVALID_NAME!!
Please help me!!!
|
|
|
|
|
If you are using a UNC name it must be fully qualified.
FindFirstFile("\\\\machnine\\share_name\\*.*",&data);
|
|
|
|
|
Can I have my VC6 still installed on my computer and install Visual Studio .NET on the same computer without any kind of trouble!?!?!?!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|