|
It should be possible - You may have to do most of the drawing yourself.
In the source you linked to, the author is only providing custom colors although the framework is
there to do the drawing.
What parts flicker specifically? Is it the text on the background?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark,
Thanks for your patience
Mark Salsbery wrote: What parts flicker specifically? Is it the text on the background?
No,Only the background is flickering(and not allways).
I don't know if this could help,but the following function is being called
every time that the list needs to be updated(i.e every 250msec).
void Frm_WKFailureList::UpdateList(iGendevBit::BitMatrixResultListType &p_FailuresListRef)
{
iGendevBit::BitMatrixResultClass *CurrentElement;
dDbsrvNotif::notificationTextType NotifText;
COLORREF SeverityColor;
UINT uiCurrentRow = 0;
UINT uiCurrentErrorsCounter = 0;
m_FailureList.SetRedraw(FALSE);
if (p_FailuresListRef.GetElementNum() > MAX_VISIBLE_ITEM_WITH_NO_SCROLL)
{
m_FailureList.SetColumnWidth(2 , 30);
}
else
{
m_FailureList.SetColumnWidth(2 , 48);
}
uiCurrentErrorsCounter = p_FailuresListRef.GetElementNum();
p_FailuresListRef.ScanInit(bTypesCnt::FROM_TAIL);
while ((CurrentElement = p_FailuresListRef.ScanNext()) != NULL)
{
switch(CurrentElement->m_Severity)
{
case iGendevBit::SLIGHT:
SeverityColor = RGB(255 , 255 , 0);
break;
case iGendevBit::MEDIUM:
SeverityColor = RGB(255 , 255 , 0);
break;
case iGendevBit::SEVERE:
SeverityColor = RGB(255 , 0 , 0);
break;
}
dDbsrvNotif::GetNotifText(NotifText , CurrentElement->m_NotiffId);
CString szError , szTime;
szError = NotifText;
szTime = CurrentElement->m_FailureTime.GetFormattedTod(bTimeTod::HH_MM_SS);
if (m_FailureList.GetItemCount() < (uiCurrentRow + 1))
{
m_FailureList.InsertItem(uiCurrentRow , _T(""));
}
static int x = 0;
szTime.Format(_T("%d") , x++);
m_FailureList.SetItemText(uiCurrentRow , 0 , szTime);
m_FailureList.SetItemText(uiCurrentRow , 1 , szError);
CHECK_LIST_ENUM IsCheckListExist = NO_CHECK_LIST;
SetLineBkColorAndIcon(uiCurrentRow , SeverityColor , IsCheckListExist);
uiCurrentRow++;
m_bListIsEmpty = FALSE;
}
if (uiCurrentRow < m_LastErrorsCounter)
{
for (UINT uiIndex = uiCurrentRow ; uiIndex < m_LastErrorsCounter ; uiIndex++)
{
m_FailureList.DeleteItem(uiIndex);
}
}
m_FailureList.SetRedraw(TRUE);
m_LastErrorsCounter = uiCurrentRow;
}
Anyway - thanks for your help,
I really appreciate it.
With best regards,
Eli
|
|
|
|
|
Hi.
I want to change some of the display properties of a computer through code.
I want to change the properties which appears on
Right click on desktop-->Properties-->Appearance Tab-->‘Effects..’ button on right bottom corner.
In that I want to uncheck all the options except ‘Show window contexts while dragging’ option.
How can I achieve this through code?
Sameer Thakur
|
|
|
|
|
Use the SystemParametersInfo API function.
|
|
|
|
|
Hi Rechi.
Thanks for reply.
I searched SystemParametersInfo() function in MSDN. I saw all the parameters which one can either access or change through that function.
But unfortunately I did not find the parameter which will help me to change the properties that I want to change.
Sameer Thakur
|
|
|
|
|
hi
how I can send numbers to play with speakers???
for example I have a an array of numbers same as:
123
2324
546
97
-65
and then I want send these numbers to sound card and then I heard sounds from
speakers.
|
|
|
|
|
Do you want to send them as DTMF tones like on a touch-tone telephone?
You can use the site http://www.dialabc.com/sound/generate/ to create an audio file containing the DTMF tone for each digit. Once you have that, all you have to do is play them in the correct sequence using PlaySound(), DirectSound, OpenAL, or your chosen sound output API.
|
|
|
|
|
Say, I have thread A and thread B, with one mutex M.
A currently owns mutex M. B is waiting on mutex M.
A then releases mutex M, and tries to reacquire it right away:
ReleaseMutex(M);
WaitForSingleObject(M, INFINITE);
Who gets the mutex? A or B?
|
|
|
|
|
That entirely depends on Windows internal thread management. Probabalistically on a single processor A will get it much more often than B because the chance of a thread switch between the two lines is relatively low sut sometimes it will happen and B will get it. It depends on a lot of things from Windows Version to speed of the processor to the number of other threads and priority levels within the system. With more than one core or processor things get even more complex
Unless you're using Windows CE which has deterministic threading then you simply can't usefully predict even the simple case. You have to code defensively as if the system sould switch threads on you in the middle of anything and everything and any one thread might be held up indifinetly, that's why MT programming is hard
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hmm... I was expecting something more of a queued process, where as soon as an object waits, it's added to the queue, and then everything that's waiting on the object gets dequeued in turn when it is finally able to acquire the lock. Is there anything that does that or am I just dreaming here?
|
|
|
|
|
No, you're not dreaming as far as I can tell (Sorry, there has been a thread on wierd sleep/wake/dreaming stuff going on in the Lounge)
You can get queued behaviour with APIs e.g.
<br />
DWORD QueueUserAPC(<br />
PAPCFUNC pfnAPC,<br />
HANDLE hThread,<br />
ULONG_PTR dwData<br />
);<br />
and by creating your own queues with other synchronisation objects. It just takes a few more step than a straight forward wait. One way is to get each thread to put an Event handle in a shared queue and then wait on that specific handle, then have a worker thread that pops events off the queue and signals them. The queue itself will need protecting against simultaneous access with its own critical sections or mutexes. Mostly if you want completely deterministic control over the order things happen in you wouldn't use multiple threads at all, just a single threaded message queue or stack. If you only want to control what order things start in but want them to happen in parallel then a thread pool and a shared queue would probably be the way to go.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
If I understand QueueUserAPC() correctly, what it does is attach a function that needs to be executed to a thread currently executing WaitForSingleObjectEx(), and then if that thread can be be signaled (bAlertable = TRUE), tells that thread "break out of your wait, execute my function, and then continue execution at the line right after the wait".
Is that more or less what it means?
Allow me to ask another question in parallel (no pun intended ):
Are there any CriticalSection-like or Mutex-like objects that can be released from any thread (doesn't have to be the thread that currently owns the CS or Mutex) without giving an error and failing to release?
MODIFIED:
It seems to me, for my second question, that CreateEvent would be the ideal solution for objects that can be waited upon, and that can be changed. Now this makes me think... why would I use a mutex (lots of overhead), or a critical section (a bit of overhead), when I can just use an event that is more flexible (allows me to signal/unsignal from any thread)?
MODIFIED AGAIN:
Nevermind, I realize the stupidity of my question, given that events must be manually set / reset, so signaling an event would cause everything waiting on it to pass through (when you only want to let one go through at a time).
-- modified at 19:42 Sunday 17th June, 2007
|
|
|
|
|
Acccording to the Microsoft Specification, WaitForSingleObject releases all threads simultaneously when the object waited for is released. If this happens on a network, each machine continues running at it's own speed, running the Remaining threads.
On a Network, All threads will be released simultaneously.
On a Single Machine, All threads will also be released simultaneously, but there is then a Scheduler which will allocate Time Slices. It can only release one thread at the time, and there is no saying to which thread it
will be.
I Think you should re-think your design, but if wakening up to order is
important I suggest that you should have More 'WaitForSingleObject'
calls to Implement your ideas
The Bottom Line is: There is NO guarantee about any following order of re-awakening threads by the operating system!! AND THAT IS GOOD
If this happens on a single machine, there is No Way of predicting which will happen first. At Any Rate if you execute a WaitForSingleObject, your thread waits,and potentially NOTHING you acquired before that call is still usefull.
Keep in mind that in theory, WaitForSingleObject() can wait for years!!
So, When it wakes up, it is important that it is followed by code which re-establishes por Updates what happened before the call, and re-establish the situation, before taking action.
LateNightsInNewry
|
|
|
|
|
Well, the original question (and design I had in mind) failed miserably after looking at a few different reasons why, so I scrapped it and made one that not only has far less synchronization (+ for performance), but also zero thread polling (another + for performance), and should work.
What I wanted to do was, if I had 3 worker threads, make the 3 threads not waste much CPU cycles if there was no work left in the queue. There are many ways of doing this and I label the first two as stupid ways (brute force, poor design), the next one a smarter but not smart way, and the last one, the best method, in my opinion:
1 - Continuous polling of the work queue for work
This wastes tremendous amounts of CPU cycles when none should be used. In theory, this is fine, if the only work you do is through the work queue, but using dedicated threads to do all the work in your program, be it big or small, is a bad idea in the first place and won't happen.
2 - Continuous polling of the work queue with a sleep timer
This wastes far less CPU cycles on polling as the thread sleeps for a little while before re-polling. The major disadvantage (and a big one at that), is the latency induced by thread sleeping. In the worst-case scenario, if all of my threads have a sleep timer of half a second, and they all sleep at the same time, work that gets called in that time may wait half a second before it can be processed. On my 2.2 GHz dual core machine, that's potentially 2.2 billion clock cycles wasted. In practice, it will be less, but you can see why this is a bad idea for a high-performance design.
3 - Blocking with critical sections / mutex
In theory, this one actually looks OK. When there is no more work, all I have to do is check a boolean value and immediately enter the critical section from the first worker thread that gets to the point where it's looking for more work and there is none. All the other worker threads that reach that point will not proceed further. This, however, means that you have to handle the case of at least one thread making it through the critical section and looping forever, wasting 100/n percent of CPU cycles (theoretically, where n is the number of active threads and where all threads have equal priority).
4 - Blocking with manually set events
The current method that I use to do this -- I'm unsure of the overhead on an event, but I would guess that it's less than that of a critical section or mutex. I've seen an article where they show acquiring/releasing critical sections have an overhead of around 40-100 cycles, and the same for mutexes is around 750-2500 cycles. I will have to double check these claims, but it comes from this article. With events, the code is simple and threads do not have to poll.
Well, that's my analysis of it... feel free to correct any incorrect assumptions I've made out of lack of experience.
-- modified at 22:17 Sunday 17th June, 2007
|
|
|
|
|
It seems like you've cracked it. In some situations Critical Sections can in fact be the least expensive synchronisation objects but in your case Events do sound better, certainly better than polling Good luck with it.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Sorry for the Delay.
I do not know what your application is about, but observe as follows_-
Synchronisation Objects (Mutexex, CriticalSections et al) are there for one reason only, and that is to regulate access to shared resources (i.e. Data!)
A Process with threads which do not acess resources shared between threads can run quite successfully without any synchronisation objects. There are many good books available which discuss this subject. From what I gather from your reply, you seem to have an Outside Project which provides data sporadically. WaitForSingleObject(...) was invented for this! You create a Named AutoReset Event with CreateEvent(...) in the Process which generates the data.
When Data is Generated, you Set the Event.
In the program that has to process the data, you open an event of the same name! Then you wait for the event to occur (By set Event in the Other Program)to fire your Code.
Hope this is helpfull
LateNightsInNewry
|
|
|
|
|
how to print a Pictrue(.bmp、.jpg) in Zebra Printer ?
how to transform the Pictrue(.bmp、.jpg) to the Cmd of ZPL II ?
help me!
help me!
help me!
My E_Mail:h_boy2008@163.com
Thanks,Thanks,...,Thanks!
|
|
|
|
|
I have the Zebra ZPL II manuals and spec at work, so not with me today. You can download up to 4? bitmaps by encoding them as hexidecimal numbers in the text of the ZPL file (whacky I know). JPEGs would need to be converted to straight bitmaps before downloading as Zebra doesn't have a JPEG decoder to my knowledge. Email me tommorow (Monday) at mfaithfull@btopenworld.com and I'll be reminded to send you a sample.
Not too many Zebra users out there. I'm curious what you use it for?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
The ZPL information you need can be found at this link www.servopack.de/Files/HB/ZPLcommands.pdf
On pages 70-75 it describes downloading and using graphics.
A graphic within a ZPL file might look like this
~DGR:85DB1DA4,00360,012,
1FFFFF03C07C000780,1FFFFF03C07C000780,1FFFFF03C07E000780,1FFFFF04C07F000780,1E
000003C07F000780, 1E000003C078003F80,1E000003C07FC00780,1E000003C07BC00780,1E00
0002C07BE00780F0,1E000003C079F00780F0, 1E000003C07807C780,1E000003C078F80780F0
,1FFFFC03C0787C0780,1FFFFC03C0783C0780,1FFFFC03C0683E0780,1FFFFC03C0781F0780,1E
000003C0780F0780,1E000003C0780F8780, 1E000003C078F00780F0,1E000003C07806C780,1E00
0003C07803E780,1E000003C07801F780,1E000003C07800F780,1E000003C07800FF80,1E0000
03C078007F80, 1E000003C07F800780,1E000003C078003F80F0,1E000003C078002F80F0,1E00
0003C078000F80F0,1E000003C078000F80F0,
And the command to place one on a label like this
^FO473,179^XG85DB1DA4,1,1^FS
DG downloads the graphic into the printer’s memory.
XG recalls the downloaded graphic from the printer’s memory into your label.
You can find the details of all the commands in the manual I linked to. (Requires PDF reader)
I don’t know much more than this myself. ZPL is certainly very strange
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hi i am creating a msi set up project in visual studio. i have to insert the installation path in regedit also. how to do this. pls help me. im new bie to visual studio
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
i have just finished compiling my application and everything is in order, but when i run it to test the different features, there is a runtime error...and it deals with access violation, hence a pointer issue. i need help fixing this and following is the call stack:
int wNode::getId() <br />
{<br />
return id;<br />
}
-----
int* workflow::getIDArray()<br />
{ <br />
int total = numNodes; <br />
int i = 0;<br />
int* IDs = new int[total];<br />
wNode* temp = first;<br />
while (temp != NULL) {<br />
IDs[i] = temp->getId();<br />
if (temp->getHasLeft()) {<br />
IDs[i+1] = temp->getLeft()->getId();<br />
i++;<br />
}<br />
temp = temp->getNext();<br />
i++;<br />
}<br />
return IDs;<br />
}
-----
<br />
int* wf_ids = dg_scenario::dg_workflow->getIDArray();<br />
any help would be greatly appreciated..i am new to c++ and thus am having a hard time tracing my steps and finding which line has the faulty pointer issue.
NOTE: the application has no compiler errors.
--
dg
|
|
|
|
|
You've left too much out to give you any real help. What is numNodes? Exactly which line in getIDArray caused the access violation? You should run your app under the debugger, put a breakpoint on the first line in getIDArray , and step through it, looking at variables.
p.s. It's much easier to read code if you use the "pre" tags.
|
|
|
|
|
numNodes is a data member in the workflow class that keeps a count of the number of nodes in the workflow.
here is the complete runtime error:
First-chance exception at 0x004fd341 in spring.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
Unhandled exception at 0x004fd341 in spring.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
the line it takes me to is:
int wNode::getId()
{
return id; <<<<----------------that one
}
is there anything else you need??
i tried putting a breakpoint in the first line of getIDArray but what do you mean "step through it"?
--
dg
|
|
|
|
|
Typicaqlly Access violation reading location 0xcdcdcdcd means you read Uninitialised Data. This is how the Compiler (Debug Version) Padds Newly Allocated Data.
LateNightsInNewry
|
|
|
|
|
I give the following advice about once a month (recently every few days); it often helps me track down the nastier heap errors:
Try enabling the page heap[^] for your process. Follow these steps:
1. Download and install WinDBG[^].
2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”.
3. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path.
5. Tick the following:
- “Enable page heap”
- “Enable heap tail checking”
- “Enable heap free checking”
- “Enable heap parameter checking”
- “Enable heap validation on call”
- “Create user mode stack trace database”
6. Press “Apply”.
7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated.
8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled.
Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.
Steve
|
|
|
|
|