|
frqftgbdafr wrote: I can make a connection with the other dialer using HTTP settings and using a www.myspace.net address, but if I switch over to FTP settings and use ftp.myspace.net, no connection.
Are you sure there's an FTP server available at the target site that is listening on the specified
port? It sounds like there isn't HTTP servers and FTP servers are not the same.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all,
I have created the button in my project like this:
<br />
CBitmapButton m_mainSettings;<br />
<br />
DDX_Control(pDX, IDC_MAIN_SETTINGS, m_mainSettings);<br />
m_mainSettings.LoadBitmaps(IDB_BITMAP1);<br />
m_mainSettings.SizeToContent();<br />
All works good, except greyed frame arround bitmap.
So I need to add a transparent color for the bitmap.
Please help me to resolve the problem.
-- modified at 14:38 Sunday 17th June, 2007
|
|
|
|
|
AFAIK, CBitmapButton doesn't support transparent colors.
You could derive a class from CBitmapButton, override the DrawItem() method, and draw the bitmaps
yourself using transparency, perhaps with GDI+ or masked bitmaps. CBitmapButton uses BitBlt()
to draw the bitmaps.
An easier (IMO) approach would be to use a toolbar control. There you can use image list(s)
which will handle transparency and true-color bitmaps easily.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
How can i do features below on a video stream, with sample grabber ?
Are there any sample for this in directshow samples of MS ?
4:3
16:9
Crop
Stretch
BEST REGARDS
|
|
|
|
|
Hi,
I have created a project in MFC and had choosen Windows Explorer style during wizrd.
I was able to add new command handlers for most of the toolbar buttons. But I
cannot add/edit command handlers for Open, Save and Save As... toolbar buttons
and menu items in the project. I think they are handled autmatically by MFC somehow,
but i want to use my code insted of the default.
Can anyone please help me out?
|
|
|
|
|
Hi,
In my project,I have to draw icon over a bitmap every 250msec.
My problem is that sometimes the drawing over the bitmap is flickering
in a very annoying way.
I know that I need to draw over the bitmap using double buffering,
and looked over some articles about it,but failed to understand
how to do it.
I can't use the classes of those articles (Safety issues... ).
Can anyone help me understand how to improve my drawing technique???
I use the following piece of code:
void Frm_WkAtol::OnTimer(UINT_PTR nIDEvent)
{
m_AtolCorridorBitmap.Invalidate();
CDialog::OnTimer(nIDEvent);
}
void AtolCorridorBitmapClass::OnPaint()
{
CStatic::OnPaint();
CRect CorridorRect;
CDC *pDC = GetDC();
static int x = 0;
pDC->SetTextColor(RED_COLOR);
pDC->SetBkMode(TRANSPARENT);
GetClientRect(&CorridorRect);
szCaption.Format(_T("Test %d") , x++);
pDC->ExtTextOut(CorridorRect.left, CorridorRect.top + 30 , ETO_OPAQUE , NULL , szCaption , NULL);
DrawIcon(pDC->m_hDC, CorridorRect.left , CorridorRect.top , m_hUavInsideAtolCorridorIcon);
ReleaseDC(pDC);
}
With best regards,
Eli;P
|
|
|
|
|
How about only invalidating only the rectangle that changes, then the only bit that needs redrawing is the icon, rather than the whole bitmap. I'd consider a separate overlaid windowless control if that doesn't work. Otherwise you need to incorporate the icon directly into the bitmap data so each change only redraws that area of the screen once. Remember to catch the erase background message and tell windows not to erase or you'll get really bad flicker whatever you do.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Here's an example of a double-buffered bitmap static control class...
#pragma once
class CDblBufferedStatic : public CStatic
{
DECLARE_DYNAMIC(CDblBufferedStatic)
protected:
HBITMAP hStaticBitmap;
CSize BackBufferSize;
CDC BackBufferDC;
CBitmap BackBufferBitmap;
void InitBackBuffer();
public:
void RedrawBackBuffer();
public:
CDblBufferedStatic();
virtual ~CDblBufferedStatic();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};
#include "stdafx.h"
#include "MyApp.h"
#include "DblBufferedStatic.h"
#include ".\dblbufferedstatic.h"
IMPLEMENT_DYNAMIC(CDblBufferedStatic, CStatic)
CDblBufferedStatic::CDblBufferedStatic()
{
hStaticBitmap = 0;
}
CDblBufferedStatic::~CDblBufferedStatic()
{
}
BEGIN_MESSAGE_MAP(CDblBufferedStatic, CStatic)
ON_WM_PAINT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
void CDblBufferedStatic::InitBackBuffer()
{
hStaticBitmap = GetBitmap();
if (hStaticBitmap)
{
BITMAP bitmapstruct;
::GetObject(hStaticBitmap, sizeof(BITMAP), &bitmapstruct);
BackBufferSize.cx = bitmapstruct.bmWidth;
BackBufferSize.cy = bitmapstruct.bmHeight;
CWindowDC WindowDC(this);
BackBufferDC.CreateCompatibleDC(&WindowDC);
BackBufferBitmap.CreateCompatibleBitmap(&WindowDC, BackBufferSize.cx, BackBufferSize.cy);
<code>
BackBufferDC.SelectObject(&BackBufferBitmap);
}
}
void CDblBufferedStatic::RedrawBackBuffer()
{
if (hStaticBitmap)
{
CDC TempDC;
TempDC.CreateCompatibleDC(&BackBufferDC);
CBitmap SrcBitmap;
SrcBitmap.Attach(hStaticBitmap);
CBitmap *pOldBitmap = TempDC.SelectObject(&SrcBitmap);
BackBufferDC.BitBlt(0, 0, BackBufferSize.cx, BackBufferSize.cy, &TempDC, 0, 0, SRCCOPY);
TempDC.SelectObject(pOldBitmap);
SrcBitmap.Detach();
<code>
CRect CorridorRect;
static int x = 0;
BackBufferDC.SetTextColor(RED_COLOR);
BackBufferDC.SetBkMode(TRANSPARENT);
GetClientRect(&CorridorRect);
szCaption.Format(_T("Test %d") , x++);
BackBufferDC.ExtTextOut(CorridorRect.left, CorridorRect.top + 30 , ETO_OPAQUE , NULL , szCaption , NULL);
DrawIcon(BackBufferDC.m_hDC, CorridorRect.left , CorridorRect.top , m_hUavInsideAtolCorridorIcon);</code>
}
}
void CDblBufferedStatic::OnPaint()
{
if (hStaticBitmap == 0)
InitBackBuffer();
if (hStaticBitmap)
{
RedrawBackBuffer();
CPaintDC dc(this);
dc.BitBlt(0, 0, BackBufferSize.cx, BackBufferSize.cy, &BackBufferDC, 0, 0, SRCCOPY);
}
else
{
CStatic::OnPaint();
}
}
BOOL CDblBufferedStatic::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
If you make your m_AtolCorridorBitmap a CDblBufferedStatic object, then you can do this in
response to the timer message:
void Frm_WkAtol::OnTimer(UINT_PTR nIDEvent)
{
m_AtolCorridorBitmap.Invalidate();
m_AtolCorridorBitmap.UpdateWindow();
CDialog::OnTimer(nIDEvent);
}
This should be flicker free
Hope you can extract something useful from this!
MArk
-- modified at 11:10 Monday 18th June, 2007
*edit* removed line that was there for testing
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark,
I couldn't ask for a better answer.
It is working perfect.
After reading your code - it seems to be so simple...
THANK YOU VERY MUCH
With best regards,
Eli
|
|
|
|
|
Hi Mark,
Just one more question....
I'm using the http://www.codeproject.com/listctrl/ReportControl.asp[^] in order to display a list control with different
rows color and icons.
The problem is that I need to update the list every 250msec,
and guess what......the list is not flicker free...
I know that updating a list control is very expensive,
but I was wondering if I can use the double buffering technique
also for the list control(which is owner drawn).
With best regards,
Eli
|
|
|
|
|
What happens if you use WM_SETREDRAW...
m_ListCtl.SendMessage(WM_SETREDRAW, (WPARAM)FALSE, 0);
...
...do stuff with the listview contents...
...
m_ListCtl.SendMessage(WM_SETREDRAW, (WPARAM)TRUE, 0);
m_ListCtl.Invalidate();
m_ListCtl.UpdateWindow();
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark,
Instead of sending WM_SETREDRAW message,I'm using
m_ListCtrl.SetRedraw() and m_ListCtrl.SetRedraw(FALSE).
But still,the list control is blinking.
I thought that double buffering drawing will solve the problem,but since the control is owner drawn,I don't have
access to the drawing functions....
Maybe it is not possible???
Thanks,
Eli
|
|
|
|
|
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
|
|
|
|
|