|
I'm searching for a method to verify if the cd-rom door is opend or closed... Any method... Does somebody knows ?...
Thanks
|
|
|
|
|
the os does this by polling the drive with TEST_UNIT_READY opcodes.
Don't try it, just do it!
|
|
|
|
|
Thank you for the answer. But can you give me an example how to use this?.. I want to test this in a mfc application; for example what I have to write in a BOOL function to recive true for open door and false for a closed cdrom door?...
10x very much!
|
|
|
|
|
Is there a c++ API or anything in the MFC library that allows you to input a text string and it speaks the text out loud? Doesn't windows come with a built in text to speech engine, as I can change the properties for it in the control panel?
If not does anybody know how to achieve text-speech translation?
Thanks
|
|
|
|
|
|
|
|
I'm using a CBitmap and a memory device context for a basic animation
Why does the screen turn black?
void CtennisView::OnTimer(UINT nIDEvent)
{
CClientDC dc(this);
OnPrepareDC(&dc);
curtime+= 0.05f;
CRect rect;
GetClientRect(&rect);
CPoint pl(0,0),ps(rect.Width(),rect.Height());
dc.DPtoLP(&pl);
dc.DPtoLP(&ps);
CDC memdc;
memdc.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
memdc.SelectObject(&bitmap);
OnPrepareDC(&memdc);
DrawBall(&memdc,ballptnew);
UpdatePos();
dc.BitBlt(pl.x,pl.y,ps.x-pl.x,ps.y-pl.y,&memdc,pl.x,pl.y,SRCCOPY);
DrawBall(&memdc,ballptnew);
UpdatePos();
CView::OnTimer(nIDEvent);
}
|
|
|
|
|
Well lets see you create an empty bitmap the size of the client area and then you draw a ball to it and blit it to the client area. Why you are calling OnPrepareDC() here I have no idea. DrawBall() may not be drawing the ball to the memdc; if so then you would have a black screen.
Basicaly the code in the OnTimer function should look something like this:
void CtennisView::OnTimer(UINT nIDEvent)
{
CRect rect;
if( m_ball.GetRect(&rect) )
InvalidateRect(&rect);
m_ball.UpdatePos();
if( m_ball.GetRect(&rect) )
InvalidateRect(&rect);
UpdateWindow();
}
Well I hope this helps a little.
Good Luck!
INTP
|
|
|
|
|
Hi,
We have created this Group, 'CUIPL Mailing Group', which we think
you might also be interested in.
CUIPL is an Image Processing Library written in ANSI C++ in order to
be platform independent.
We thought that it would be more useful if we put it on the internet
as an open source, this way people can use it, but most important
they can extend it to cover areas not covered in the initial release.
This library is intended to be a tiny step towards a huge arabian
open soucre community, where we can build the software we need.
We don't have to rely on the west to supply us with - at least - our
software needs, we can do our own, and we are old enough to do so
we have the knowledge, experties, and the tools to achieve our goal.
So,
WHAT ARE WE WAITING FOR!!?
the group address is
http://www.smartgroups.com/groups/cuipl
Email us back if you need any help, or what it's all about...
Regards
Ahmed Mohamed Abdelsalam am_abdelsalam@msn.com
Mohamed Galal El-Din Mohamed eng_mg@yahoo.com
|
|
|
|
|
Hiya, I think I'm just being dumb, but I'm having a hard time deciding exactly where to change the font, size, etc. for controls on my form.
I have an MDI project with CFormView as its base; nothing very complicated, basically just a label at the moment anyways.
I'd like the label to not be 8 point times or whatever; but that's not doable visually for some reason (like it is in VB for Excel or what have you). I gather I want to use CWnd::SetFont which should be a member of my IDC_STATIC control, but VC++ seems to disagree with my placing of the function.
I don't doubt it's just been too long since I used VC++ to remember something this obvious ... TIA
-Joe
|
|
|
|
|
I recommend using
http://www.codeproject.com/staticctrl/clabel.asp[^]
It gives you a great deal of flexibility over static controls.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
All static controls share the common control ID IDC_STATIC . IMHO, if you need to change the font, size, etc. of static controls at run-time, the first step is to change the control ID from IDC_STATIC to something more meaningful e.g. IDC_STATIC_NAME and then in your dialog's OnInitDialog , create a CFont , and use CWnd::SetFont to apply the changes.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Hi..
what can i use to know the language of string like if it English or Arabic?
|
|
|
|
|
code an algorithm on your own, I've never heard of any other way.
Don't try it, just do it!
|
|
|
|
|
HOW I CAN HIDE MY FIRST DIALOG IN A MFC APP?
|
|
|
|
|
You can hide any window using ShowWindow(SW_HIDE)
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Hi,
I am working with the MFC which is connected to the database using recordset. However, I currently encounter some problem. Let me explain further what this program is abt.
For this program that i am working on now, i have an update button. Also, there are 3 parameters which i want to keep changing the values on its own once the update button is being clicked. This might need to use "while loop" and i would like to change the values between the range of 1 to 5 only. This looping will only stop when i click the close on the window itself.
However, the problem now is that i need to change the values when i input it myself and press the update button before it can be stored inside the database.
So i am hoping that anyone who knows how to get this thing workin to give me some ideas on how to go abt doin this.
Thanks
|
|
|
|
|
The solution is very simple: THREADS (it's easy too )
I give the sample code in Windows API. I m sure u can port it to MFC. I have given MFC portions that i can predict(lol, i dont know much MFC).
//First of all this is the thread which will continiously update ur value when update button is clicked.
<small>
HANDLE hthread; <small>
int idThread; <small>
DWORD WINAPI UpdateThread(LPVOID lpParameter)<br />
{<br />
while(1) <small>
{<br />
<small>
}<br />
} //
This function is called when Update Button is clicked(name it according to ur program)
OnUpdateButtonClick()<br />
{<br />
<small>
hThread=CreateThread(NULL,0,UpdateThread,0,0,&idThread);<br />
<small>
} Now thread executes repeatedly irrespective of ur main program code.
We want to stop the thread when STOP button is clicked. So we write the following code:
OnStopButtonClick()<br />
{<br />
<small>
TerminateThread(hThread,0)<br />
<small>
}
I think, this will solve ur problem, ask if u have any doubts.
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi hi,
Thanks for the codings that is provided. Much appreciated. However, i am unfamiliar with using THREADS. But will give it a try on the codings that you provided. In the meantime, is there any other solution to this problem??
Thanks lots
|
|
|
|
|
Hey, i've got another solution for u (that too WITHOUT threads )
//----------make a global var----------
//glo can take two values>>
//0:do nohting; 1:update the values; int glo=0;
DO idle-time processing- i think the function is OnIdle() for CwinApp (i'm not sure about MFC, find it urself)
The OnIdle function is executed when ur window doesnt receive any key input.
OnIdle is executed all time but it will update ur values only when glo is 1.
The following code will ensure this:
CWinApp::OnIdle()<br />
{<br />
if(glo==0)<br />
;
else if(glo==1)<br />
{<br />
}<br />
}
Inside Update Button click function, all u have to do is to set the value of glo to 1.
//---------Update button click rotine-----
OnUpdateClick()<br />
{<br />
glo=1;<br />
}
Inside Stop Button click function, all u have to do is to reset the value of glo to 0. This will stop the update.(;))
//---------Update button click rotine-----
OnStopClick()<br />
{<br />
glo=0;<br />
<br />
}
Thats allllllll...........
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi,
For this thread function, i have some doubts which i have stated below. Can kindly explain to me? Thanks
For this function that you have stated:
DWORD WINAPI UpdateThread(LPVOID lpParameter)
I just need to copy down or do i have to state any values to the lpParameter?
Here, i have also attached part of the codings that i have done, but i have tried the methods that you have given but it dun seems to work the way as you state. The coding stated below, the while loop is working and the database will be updated on click the UpdateDB. however, once i click on the update button, the whole program seems to hang.
<br />
int check_exit=0;<br />
<br />
void CUpdateView::OnUpdatedb() <br />
{<br />
<br />
CUpdateDoc* pDoc = GetDocument();<br />
UseRecordset* pUseRecordset = &pDoc->m_UseRecordset;<br />
int x = 5;<br />
do<br />
{<br />
pUseRecordset->Edit();<br />
<br />
pUseRecordset->m_propatime = m_propagation*x;<br />
<br />
pUseRecordset->Update();<br />
<br />
if (check_exit = 0)<br />
check_exit=1; <br />
}while(check_exit!=1);<br />
<br />
}<br />
<br />
void CUpdateView::OnExit() <br />
{<br />
check_exit = 0;<br />
}
Thanks a million,
dreamerzz
|
|
|
|
|
if (check_exit = 0)
If this is what you have coded, then change it to:
if (check_exit == 0)
LOOK CLOSE AT UR PROGRAM, it doesnt come out of the do-while loop
Well, if you have written that by mistake and are actually using if (check_exit == 0) then your program is hanging because it keeps looping inside the do-while LOOP. ACTUALLY UR PROGRAM APPEARS TO HANG(loops & loops and loops) AS IT DOESNT RETURN CONTROL BACK TO WINDOWS(ur main program), so you can no longer interact with any other buttons.
The trick is to run a continious LOOPING do-while LOOP, but we want it to run seperately from our main program. HERE COMES THE THREAD:::>>>
int loop=1;
DWORD WINAPI UpdateThread(LPVOID lpParameter)
{
CUpdateDoc* pDoc = GetDocument();
UseRecordset* pUseRecordset = &pDoc->m_UseRecordset;
int x = 5;
while(loop==1)
{
pUseRecordset->Edit();
pUseRecordset->m_propatime = m_propagation*x;
pUseRecordset->Update();
}
}
THE ABOVE FUNCTION DOES NOTHING. IT DOESNOT START A NEW THREAD. It is like any ordinary function function defination. Its has to be called from somewhere to make it execute. BUT UNLIKE ORDINARY FUNTIONS, we will not call UpdateThread(<<something>>) as it will not start a new thread.
And the name "UpdateThread" is purely arbitrary. You can name the thread as "dreamerzz Thread()" or "CrapThread()" or "BoomBoom()" or whatever you want.
Now, we want this thread to start when we click Update buttom. so, we write::>>>
HANDLE hthread;
int idThread;
void CUpdateView::OnUpdatedb()
{
hThread=CreateThread(NULL,0,UpdateThread,0,0,&idThread);
}
You dont have to explicitly end the thread as it will automatically terminate when the value of "loop" becomes 0. (To explicitly terminate a thread you can use the function TerminateThread(hThread,0); )
void CUpdateView::OnExit()
{
loop = 0;
}
Ask if u have doubts
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hi,
Thanks for the help given.;)
dReaMerzZ
|
|
|
|
|
BOOL CTest02Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
|
|
|
|
|