|
I just tested your code by placing the Recieve function within a clas and get that exact error message. You need to define the function as static if you're going to use a member function as the first parameter of all instance functions is the this pointer.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Although I don't totally understand how this works, here is a sample of the code that I'm using.
// Declared in the header file.
bool StartReminder();<br />
static UINT ThreadForReminder(LPVOID pParam);
// When a user presses the remind me button I spin my //thread.
void CConstantReminderDlg::OnRemindMeButton() <br />
{<br />
<br />
if(!this->GetThreadIsSpinning())<br />
this->SpinThread();<br />
}<br />
}
UINT CConstantReminderDlg::ThreadForReminder(LPVOID pParam)<br />
{<br />
UINT returnCode = 0;<br />
CConstantReminderDlg* pObject = (CConstantReminderDlg*)pParam;<br />
<br />
if (pObject == NULL)<br />
return 1;
<br />
pObject->StartReminder();<br />
return 0;
}
void CConstantReminderDlg::SpinThread()<br />
{<br />
this->SetThreadIsSpinning(true);<br />
<br />
::AfxBeginThread(ThreadForReminder,this);<br />
}
// The user has requested the program begin and the thread // for reminder dialog has been spun.
bool CConstantReminderDlg::StartReminder()<br />
{<br />
<br />
CEvent wakeUpTimer(false,false,"probeDroid",NULL);<br />
HANDLE hHandle = (HANDLE)wakeUpTimer;<br />
COleDateTime timeStart,timeNext;<br />
<br />
this->SetUserWantsToQuit(false);<br />
<br />
|
|
|
|
|
Send me your email (tarcher@mindspring.com) and I'll send you a very simple example of using AfxBeginThread. You can then compare, discern what you're doing wrong and post what you find here for anyone else that runs into the same problem.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I have to create a dialog box where i will get the values for the X and Y coordinates and then pitch of the rows and columns. taking these values i have to create a kind of a grid which shows the pattern in which holes will be drilled in a machine. whether a hole is drilled or not will depend upon the bit pattern entered by the user 1 for hole and 0 for none.
i have to convert this in an ascii format and display it.
Any ideas on how to do it? I just know the V of Visual C++ and i am stuck.
Every problem has a solution!
|
|
|
|
|
you mean converting int to readable ascii??
char buffer[256];
sprintf( buffer, "%i", iInt );
...
sprintf required stdio.h, wsprintf is the windows api equivalent
Don't try it, just do it!
|
|
|
|
|
Hi I'm new to C++ programming, I would like to know if the below information could be done? If so, how and what would the coding look like?
C++ Dive Log Page Program:
Create a class DiveLogPage, along with a main routine to create & manipulate instances of DiveLogPage (manipulating them enough to “prove” that the class works properly) Provide the following member functions: constructor function ( with dialog, as described below), >><<, and displayDiveLogPage. Note that >> and << should be “symmetrical” (i.e. you should be able to read back what was written). The displayDiveLogPage member function should do a “pretty / reasonable” display of the DiveLogPage (i.e., display the various data members on the screen with headers).
A dive log consists of an entry for each dive that diver has made. Our dive log entries (i.e.., our DiveLogPage) will consist of the following items: dive number, start time, stop time, bottom time, average depth, maximum depth, starting tank pressure, and ending tank pressure. Data types for these items are shown in the table below.
integer dive number, average depth, maximum depth, starting tank pressure, ending tank pressure
Time start time, stop time, bottom time
The DiveLogPage constructor function should begin a dialog to get “most” of the items from the user( i.e.., user input prompts and input statement) Get the following items directly from the user: start time, stop time, average depth, maximum depth, starting tank pressure, and ending tank pressure. Data validation is required as follow: stop time > start time, maximum depth >= average depth, ending tank pressure < starting tank pressure. You should then calculate the bottom time (as stop time-start time). The class should maintain a static variable to set the dive number for the user (i.e.., first dive entered is dive number 1, second dive entered is dive number 2, etc...). Note that when reading a dive log from a file you must make sure that dive number is properly set as the user may create more DiveLogPages.
Create an array of 5 DiveLogPages. The main routine should be menu-driven, giving the user the following options:
0: quit
1: make an entry in the dive log
2: correct an entry it the dive log
3: display the current dive log
4: write the current dive log to file
5: read a dive log from a file
The “correct an entry in the dive log” option should first get the dive number for the entry that the user wants to change, and then display the following menu:
0: done making changes
1: change start time
2: change stop time
3: change average depth
4: change maximum depth
5: change starting tank pressure
6: change ending tank pressure
Instead of an array of 5 DiveLogPages, use dynamic allocation to allow user to create as many DiveLogPages as they want.
Divers generally store text information as well as numeric. Add 2 fields: dive site and dive notes. Dive sites should store up to 25 characters (including blanks), and notes should store up to 100 characters (including blanks). Get these values from the user as part of the constructor function dialog. Include options to correct the fields (under “correct an entry in the dive log”), but you only need to allow the user to replace them, not edit them.
C++ Newbie
|
|
|
|
|
homework is it ?
the specs are quite nice, I don't kwow where to start to help you, maybe you can start on your own and come back with specific questions.
I'll give you the following head start :
class DiveLogPage
{
};
I sound harsh, but you can also ask your teacher (or whoever is in charge) for pointers and tips.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Create a CDiveLog class with all the params you mentioned i.e.:
class CDiveLog
{
private:
int nDiveNumber;
double dAvgDepth;
...
public:
CDiveLog();
CDiveLog(const int& DiveNumber);
SetDiveNumber(const int& DiveNumber);
...
};
And then to manage multiple dive logs, use the std::vector -->
std::vector<CDiveLog> vDiveLogs;
for(int i=0; i<nLogs; i++)
{
vDiveLogs.push_back(CDiveLog(i));
vDiveLogs.at(i).SetDiveNumber(iSomeNumber);
}
...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Yeah, that is very easy to write. I wish my boss gave me specs like that.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
No kidding. I'm used the old "I'm going upstairs for specs. You guys get started coding" bit
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Tom Archer wrote:
No kidding. I'm used the old "I'm going upstairs for specs. You guys get started coding" bit
That's just what is heard, when in all reality he is muttering "I'm going upstairs to starting writing the initial specs that won't make it past the first design meeting we were suppose to have two months ago, you guys get started coding."
-Nick Parker
|
|
|
|
|
I have an array of gray scale pixel values ranging from 1-1024. When I display them by creating a bitmap in a Memory DC and then StretchBlt into screen DC, it somehow converts to a color image, where most of the image color is Magenta. I tried to create and set the Palette of screen DC before calling StretchBlt, but doesn't help. Any suggestions?
|
|
|
|
|
It sounds to me like you're spreading 10 bit grayscale data into 24 or 32-bit RGB data. To get this to work, what you need to do is scale your grayscale info to be 0-255, then set each of the RGB bytes in the Memory DC to that same value.
So, for example, if you had a grayscale value of 512, scale that down to 128 (512/1024 == 128/256). Then copy that 128 into the R, G and B bytes of the bitmap you wish to display. My guess is that your values are spreading into the R and B bytes, causing the Magenta hue. To get gray, each R, G and B must be the same value.
Hope this helps.
|
|
|
|
|
I know that DirectShow and Windows Media SDK can both play back almost any type of AVI file, BUT:
I want to play in REVERSE. In other words, while a video is playing, I want to hit a "reverse" button and have it play backwards - just like in some of the video editing packages available out there. The catch is that I'd like to do this on an AVI file containing native DV information (MSDV codec).
Anyone know how to do this?
Thanks
Brian
|
|
|
|
|
i don't really know, but try the IMediaSeeking interface(description from sdk).
Don't try it, just do it!
|
|
|
|
|
thanks, but....
the IMediaSeeking interface can only "seek"... not play in reverse. It can also set the playback rate, but that's it.
I love all these great interfaces that M$ provides, but if you are missing just one important function, you have to re-think your entire approach.
I read someplace that playing uncompressed video in reverse is MUCH easier than playing let's say, MPEG in reverse. In uncompressed video, I can display a single frame without having knowledge of any other frames in the video. This is unlike compressed video (like MPEG), which needs to "figure out" what the next frame will look like based on the previous frame.
So I'm figuring I can write an application that will hold the video frames in memory. I can then "pump" the frame information forwards or backwards into the "display" routine. In this way I can achieve forward or reverse playback.
Looks to me that I won't be using DirectShow to play back my DV avi's.
Can anyone comment on this?
|
|
|
|
|
Hi,
I have a Mdb file on my WebPage http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb
1) If I use strConnect = "URL=http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb" or "provider=MSDAIPP.DSO;data source=http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb" ...
then I am able to connect to it ... but I could not open the table "Answer" in it (display error)
2) If I use the same database but in local computer strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\ClientDatabase.mdb" ... then I can open the table "Answer" in it!
3) If I use strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb" ... then I could not connect to it!
Note: I am able to open (using my MS Access) manually directly http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb without any problem!
Can anyone help to see why I had those problem in 1) & 3)
Many thanks,
Anh Truong
Here are my codes in VC++
<br />
CString strConnect; <br />
<br />
strConnect = "URL=http://www32.brinkster.com/atechcom/db/ClientDatabase.mdb";<br />
<br />
pdbConnect->Open ((bstr_t) strConnect, "", "", adModeUnknown);<br />
<br />
_RecordsetPtr pList;<br />
_bstr_t strSQL;<br />
_variant_t vNull, var;<br />
CString temp;<br />
<br />
vNull.vt = VT_ERROR;<br />
vNull.scode = DISP_E_PARAMNOTFOUND;<br />
<br />
pList.CreateInstance (__uuidof (Recordset));<br />
pList->PutRefActiveConnection (pdbConnect);<br />
<br />
temp.Format ("SELECT * FROM Answer");<br />
strSQL = temp;<br />
<br />
pList->Open (strSQL, vNull, adOpenForwardOnly, adLockOptimistic, adCmdText);<br />
<br />
if (!pList->GetadoEOF())<br />
{<br />
var = pList->GetCollect ("Conf");<br />
m_text = var.bstrVal; <br />
UpdateData (false);<br />
}<br />
pList->Close();<br />
|
|
|
|
|
I can give you an answer for the third case. ADO will not open websites. The jet engine will not open websites. I think that there is a very good reason for it. The file needs to be downloaded before you can work on it, and I don't think OLE DB can do that. In any case, your 2nd choice is the correct way of connection to an Access file.
As for the 1st case, I have never heard of MSDAIPP.DSO, so hopefully somebody else can help you on that.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Hi,
Thanks, but we can not use the download/upload (or copy) ... because while we are doing that, the database still update its contents & can not be orverwrite later! We must access it directly to see what are changing!
Regards
|
|
|
|
|
ATC wrote:
We must access it directly to see what are changing!
OLE DB provides access to any data source for which there is an OLE DB provider. These data sources include email
stores, object databases, network directories, and other nonrelational data stores. A website doesn't fall in any of these categories.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
download the file to the temp folder, and everything works well
Don't try it, just do it!
|
|
|
|
|
Hi,
Thanks, but we can not use the download/upload (or copy) ... because while we are doing that, the database still update its contents & can not be orverwrite later! We must access it directly to see what are changing!
Regards
|
|
|
|
|
no way... this kind of database doesn't support your wishes!
better try ms sql or mysql
Don't try it, just do it!
|
|
|
|
|
I just went through this same problem with an app I am developing. The drivers for Access do not allow remote connections. I had to export my Access database and import it into MySQL and the ODBC driver for MySQL allows you to specify a URL for the server and the database name on the server.
I'm going to live forever or die trying!
|
|
|
|
|
I can define an array in my local variables (to a certain function), but I am having trouble defining that array as a global array that I could use in all of my subfunctions.
Here is how I define the variable in my local area (this works)
<br />
void CMyDialog::OnMyFuntion()
{<br />
<br />
double f1, m_div;
double ValuesArray[200];
<br />
ifstream inf; <br />
inf.open("Testdata1tab.txt");
<br />
for (int i=0; i < 199; i++)
{<br />
inf >> f1;
ValuesArray[i] = f1;
<br />
Value = ValuesArray[i]/m_div;
}<br />
<br />
inf.close();<br />
}<br />
}<br />
When I try to define the array in my .h file as a public variable, I get a runtime error. Here is how I try to define the array:
<br />
class CMyDialog : public CDialog<br />
{<br />
public:<br />
CMyDialog(CWnd* pParent = NULL);
enum { IDD = IDD_MY_DIALOG };<br />
double ValuesArray[200];<br />
I leave the .cpp file at the top the same, except that I remove the double ValuesArray[200]; line.
I am probaly doing several things wrong. Any help will be more than welcome.
I wish I could type better ...
|
|
|
|
|