|
So you want to block the keyboard and mouse input of that console application?
Величие не Бога может быть недооценена.
|
|
|
|
|
yes. Is it possible? or i shd go 4 dialogue based application.?
|
|
|
|
|
Yess 100% possible
you need to include these files is needed
#include <afx.h>
#include <winable.h>
But i cannot understand the purpose of doing so.
Величие не Бога может быть недооценена.
|
|
|
|
|
i wrote like this
#include <iostream>
#include <windows.h>
#include <winable.h>
using namespace std;
int main()
{
BlockInput(true);
Sleep(5000);
return 0;
}
its working fine for 5000ms only. but my motto is to unlock the system while i press esc key. how to do this? plz help.
|
|
|
|
|
BlockInput itself is done to block any keyboard event till some action is over. So how can it be possible to click of ESC to work?
Величие не Бога может быть недооценена.
|
|
|
|
|
I new at C++ but i can't seem to figure out whats wrong with my code.
//Specification: Display a menu
//Find Errors in this program
#include <<iostream>>
int main ()
{
cout << "Choose From Martha's Menu:/n";
cout << "1 - Dinner" cout << endln << 2 - "Lunch: ";
cout << endln << "3 - Breakfast";
cout << "Enter a number:"
int Choice = 0;
cin >> choice;
cout << "\n You Choose " << choice;
return 0;
}
|
|
|
|
|
PLease try to learn the usage of syntax of C++. The syntax used in your code is wrong.
Syntax related error can be cleared only working with it.
Which you have do
I prefer you to study with Learning C++ A hands On Approach by Eric Nagler. [^]
Well your case firstly #include <iostream>
you didn't specified the namespace.
Either use
using namespace std
std::cout
and next is related endln, actually that is endl.
Please learn using the text, it is better for you.
Величие не Бога может быть недооценена.
|
|
|
|
|
halestorm 222 wrote: i can't seem to figure out whats wrong with my code.
How do you know something is wrong?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have calling Initialize function with these parameters
Initialize(this->GetDC(),200,200);
Unhandled exception occurred at: m_pBitmap->CreateCompatibleBitmap(pInputDC,width,height);
void Initialize(CDC* pInputDC,int width, int height)
{
CDC *m_pDC;
CBitmap* m_pBitmap;
m_pDC->CreateCompatibleDC(pInputDC);
m_pBitmap->CreateCompatibleBitmap(pInputDC, width, height);
m_pDC->SelectObject(m_pBitmap);
m_pDC->Rectangle(0,0,width,height);
}
This is shown in call stack when exception occurred:
mfc80ud.dll!CGdiObject::Attach(void * hObject=0xb90510f0) Line 1157 + 0x3 bytes
mfc80ud.dll!CBitmap::CreateCompatibleBitmap(CDC * pDC=0x004bf954, int nWidth=336, int nHeight=189) Line 251 + 0x25 bytes
AxGraph.ocx!CGraphCtrl::Initialize(CDC * pInputDC=0x004bf954, int width=336, int height=189) Line 27
I could not understand why is this happening. Help to resolve the issue.
|
|
|
|
|
Did you allocated memory for of CBitmap* and CDC* using new?
Величие не Бога может быть недооценена.
|
|
|
|
|
Thanks. I forgot to allocate memory. After allocating memory its working.
Thanks again
K.Masood
|
|
|
|
|
Hi,
Usually I instantiate my CDialog based classes in my view class. Then CMyView class typically creates a modal dialog and then launches a function on OK from which I can easily access the dialog variables.
Unfortunately, the wizard implementation of CPropertySheet has no default constructor. So you are forced to construct it in the view function that is called from a toolbar menu or similar. Then the property page variables have to be duplicated in CMyView class and copied. I have 2 books that show it done this way.
Here is the wizard CPropertySheet constructor code-
CMyDlg::CMyDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CMyDlg::CMyDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
And the constructor in CMyView looks like -
CMyDlg CMyDlg(_T(" "),this);
or
CMyDlg CMyDlg(_T(" "));
if (CMyDlg.DoModal() == IDOK){
(both verified to work)
If I now add the appropriate default constructors to the PropertySheet .h and .cpp files -
CMyDlg();
CMyDlg::CMyDlg():CPropertySheet()
{
}
I then instantiate CMyDlg in the view class instead of constructing it in the menu function.
I don't get any compile errors but the dialog (property page) does not display when DoModal is called even though there is no run time error.
I suppose I should admit defeat and call the constructor as designed.
modified on Friday, October 30, 2009 12:55 AM
|
|
|
|
|
HI all,
I have written some code about changing Modification Time and Access Time in File.
My code tries to change both time every one minute.
But, sometimes, Modification Time is not changed by _utime() with 'NO ERROR' after running few hours. (but, Access time is changed.)
Below is the code used to changed times.
if anyone know why the problem is appeared and how i can solve,
Please, let me know
Thanks.
+++++++++++++++++++++++++++++++++++++++++++++++
BOOL SetModificationTime( time_t t )
{
struct _utimbuf uti;
uti.actime = t;
uti.modtime = t;
if (_utime(szPath, &uti))
{
OutputDebugString("Error : Faid to change time");
return FALSE;
}
}
--------------------------------------------------
|
|
|
|
|
|
Thank you for answer~
But, SetFileInformationByHandle need at least Windows Vista OS.
My Program's minimum supported client is Windows 2000. T.T
is There any other way to solve?
Please Let me know.
Thanks.
|
|
|
|
|
Have you tried SetFileTime() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I wrote the below code in an attempt to set a 500ms timer. CreateWaitableTimer returns a valid handle and SetWaitableTimer() returns 1 indicating success, however TimerAPCProc() never gets called. Can anybody see what's wrong with this code?
VOID CALLBACK __stdcall TimerAPCProc(LPVOID lpArgToCompletionRoutine, <br />
DWORD dwTimerLowValue, DWORD dwTimerHighValue)<br />
{<br />
<br />
}<br />
<br />
void SetTimer()<br />
{<br />
m_hTimer = CreateWaitableTimer(NULL, false, NULL);<br />
LARGE_INTEGER liInterval;<br />
liInterval.QuadPart = -500000000;<br />
int dSuccess = SetWaitableTimer(m_hTimer, &liInterval, 0, TimerAPCProc, NULL, false);<br />
}
Thanks for any help you can offer.
|
|
|
|
|
|
Thanks for the reply and information. The timer is being created in the main thread so it's definitely not a problem of it exiting too soon. I also tried setting the time to -1 just to try and get it to call the TimerAPCProc but still it wouldn't.
I solved the problem by switching to SetTimer(). For some reason I thought SetTimer() worked in seconds rather than milliseconds and that's the only reason I was using SetWaitableTimer(). I was looking for an alternative time and noticed SetTimer() took a value in milliseconds so it was fine for what I needed.
I still don't understand why SetWaitableTimer() wouldn't work but it doesn't really matter now.
|
|
|
|
|
Hello
Can anyone tell me how to read and write to a binary file?
Any sample code will be of great help.
I want to write multiple structures into a binary file
and then read it one by one.
Thanks in advance
|
|
|
|
|
Just CreateFile with binary access, write it, seek to the front, and read it back record by record. If you want random access, then the records must be the same size. If you want variable length records, just precede each binary record with a DWORD with the record size when you write it, then when you read it back, read the DWORD to get the record size, then read the data block, - this also implies that the file must be sequentially accessed both for writing and reading.
Dave.
|
|
|
|
|
#include <stdio.h>
typedef struct _myStruct
{
int x;
int y;
int z;
} myStruct;
int main()
{
FILE *fp;
char *fileName = "output.dat";
char *mode = "wb";
myStruct theArray[10];
int i;
for (i=0; i<10; i++)
{
theArray[i].x = i;
theArray[i].y = 10-i;
theArray[i].z = i * (10-i);
}
fp = fopen(fileName, mode);
fwrite(theArray, sizeof(struct myStruct), 10, fp);
fclose(fp);
}
|
|
|
|
|
Thanks for the sample code.
I am working on C++ using WIN32 API's in Visual Studio 2003.
In the function here for binart read/write,
i am using the functions, _write and _ read.
Does that make any difference in writing/reading? compared to using fwrite and fread?
|
|
|
|
|
|
dipuks wrote: i am using the functions, _write and _ read.
See here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|