|
It looks like it would be a problem in how you are managing your job pointers. You have them stored in a std::vector?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
>>It looks like it would be a problem in how you are managing your job >>pointers. You have them stored in a std::vector?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No, I did not use std::vector. I use my own linked list (queue) to store my job pointers. And, when I try to remove the "store operation" to list (i.e, now I did not keep these job pointers), same thing. So, I guess the problem should be on the thread or thread function ?
But the above code is fine in this case: job 1 is triggered before job 2 and, job 1 is also "done" before job 2.
I still don't know why.
|
|
|
|
|
I got it already ! Thanks for everybody's reply.
JOBINST pJobObj = (JOBINST) lpParam;
pJobObj->hMailEvent = CreateEvent( 0, FALSE, FALSE, "Mail Thread Event" );
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Wrong for the event string - "Mail Thread Event" !!
Every event should be unique !
So, the correct one is something like this:
char strMailEvent[ 64 ];
wsprintf( strMailEvent, "MyMailEvent %x",( DWORD )pJobObj );
pJobObj->hMailEvent = CreateEvent( 0, FALSE, FALSE, strMailEvent );
because every pJobObj is unique (allocated from heap), I use this as key for every event.
|
|
|
|
|
Ok,... I would rather use the help files that C++ comes with rather than ask you guys all the time. "no offence" There are good reasons for this, 1. dont have to bother you with stupid questions i can first find out on my own. 2. It would just be more helpfull for me
ok... i wanted to change the color of the background using win32 console app.
the file said... "exactly "
---------------------------------------------------
CDC::SetBkColor
virtual COLORREF SetBkColor( COLORREF crColor );
Return Value
The previous background color as an RGB color value. If an error occurs, the return value is 0x80000000.
Parameters
crColor
Specifies the new background color.
Remarks
Sets the current background color to the specified color. If the background mode is OPAQUE, the system uses the background color to fill the gaps in styled lines, the gaps between hatched lines in brushes, and the background in character cells. The system also uses the background color when converting bitmaps between color and monochrome device contexts.
If the device cannot display the specified color, the system sets the background color to the nearest physical color.
CDC Overview | Class Members | Hierarchy Chart
See Also CDC::BitBlt, CDC::GetBkColor, CDC::GetBkMode, CDC::SetBkMode, CDC::StretchBlt,::SetBkColor
---------------------------------------------------------------
Now,... how do i use the info that this help file tells me, for that i can do what i want to do in my program? "that is, change the color to white, or blue"
How do i read this and use it?
Thanks All!
~SilverShalkin
|
|
|
|
|
SetBkColor is not related to the console. It looks like you looked up a function from MFC, and MFC is only useful for developing windows applications.
SilverShalkin wrote:
How do i read this and use it?
If you were using MFC, you would create a CDC object. Then you would be able to call the member function of CDC called SetBKColor. One more thing to note, is that a COLORREF can be created
with the RGB() macro, were you provide the RGB color combinations to create a new color.
If you wanted to set the background color to red, you would do this:
void DoSomething (CDC *dc)
{
dc->SetBkColor(RGB(255,0,0));
...
}
I am sorry I do not know console programming well enough to tell you how to change the background color.
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!
|
|
|
|
|
SilverShalkin wrote:
i wanted to change the color of the background using win32 console app.
[...]
CDC::SetBkColor
This is a GDI functions that has nothing to do with console I/O. Have a look at SetConsoleTextAttribute .
|
|
|
|
|
Ok... my mistake... "that makes things a little bit easier to understand
How do i find files only on Win32 console App.'s that i can use to program? and how do i know wether it is a mfc or win32?
Thanks!
~SilverShalkin
|
|
|
|
|
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!
|
|
|
|
|