|
MFC supports querying and updating ODBC databases, so take a look at CDatabase and CRecordset, together with an ODBC connection to your .dbf file.
|
|
|
|
|
How can I open a Foxpro Table using Visual C++ 6. Please help me...........
I need to use unicode charset.For example, (In richEdit)
|
|
|
|
|
I hate to trouble everyone with such a simple question but I’ve been stuck on this for about a day (I am not that experienced in VC++). I’ve already tried searching everywhere but didn’t find anything that helped me yet. I have a dialog based VC++ program that takes user input and solves a nonlinear partial differential equation. Anyway, I wrote a different dialog based VC++ program which plots the results. I am currently saving the results from the first *.exe to a data file and using ShellExecute() to open up the plotting *.exe file, import the data, and plot the results (just to get things working).
Obviously this approach is poor. I would like to avoid saving the data (an int, 2 1D arrays, and 1 2D array) to the temp file, and get a single application that performs all of the current functions. I tried adding a new dialog to the main project and then selecting “Create a new class” to associate with it. I am able to open this dialog from the main one using
Plotter dlgplot;
dlgplot.DoModal();
but can’t get data to it.
My question is: how can I pass the data from the main class to my plotting one?
Thank you in advance I appreciate any help.
|
|
|
|
|
the standard approach is to create member variables in the dialog class that either hold the actual data or that can be used by the dialog to fetch the data. your main class sets these variables before calling DoModal, and your dialog uses them in its InitDialog function to set up / fetch / whatever the data.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
I tried doing as you suggested, however, my second dialog's code does not include
the OnInitDialog() function (also recall it has a different class from the main dialog). I added the OnInitDialog() function manually to the second dialog’s *.cpp and *.h files. My code compiles but now the second dialog window no longer opens (it is invoked by a pushbutton from the main dialog) and my main window actually closes when I try to open the second window.
Also, when I tried adding a new member variable "ClassWizard" only allowed be to add a control? What am I doing wrong? Is this really the best approach for my problem?
|
|
|
|
|
Nick Usechak wrote:
I added the OnInitDialog() function manually to the second dialog’s *.cpp and *.h files.
try removing them, them using the ClassWizard to add a handler for the "WM_INITDIALOG" message.
Nick Usechak wrote:
Also, when I tried adding a new member variable "ClassWizard" only allowed be to add a control?
that's probably because you had the OK or Cancel button selected on the control selector (there's really no way not to have one of them selected on a new dialog).
but, CW is most useful as a way to create and manage message handlers and member variables that are associated with controls. it would be better named "ClassMessageWizard" or something - it's not a generic C++ class handler. if you want to add a member variable to your class, just put it in the .H file for your dialog and either make it "public" or make it private and add public Get/Set functions to get and set the value (the latter is the preferred way, for OO reasons).
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks a lot Chris!
I got it working. In hindsight your instructions totally make sense since I am just trying to pass data from one class to another. I just never thought of everything in VC++ as classes before even though I always knew they were – tells you how experienced I am in C++.
Anyway, once again thanks; you saved me a lot of time.
-Nick
|
|
|
|
|
You may want to abstract things a bit further and make a container class for your data. Then you can make methods to perform your calculations and easily pass the data object (as a pointer or reference) between dialogs within your app. As Chris mentioned, it would be best to have Set/Get methods in the data container class to access its data.
|
|
|
|
|
What's the difference between
system("myGame.exe");
and
system("start myGame.exe");
?
And how does one use system()? What is the return type? How can one kill a process started by system("start myGame.exe -machinefile bla")?
Is fork() just basically spawns multiple clones on localhost (the same machine)? And can fock() be given additional parameters so that the newly spawned process is executed differently?
|
|
|
|
|
The answer to all of your questions can be answered with: don't use system() . You need to use this instead.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
system just executes a command as you would have typed in DOS...
looking at the 'START' help, it says that it "Starts a nedw windows to execute the programme or the typed command".
in DOS, type START /? to have more details.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hello,
I'm writing a windows application with visual c++ that runs an external process which eventually consumes 100% of the cpu (even at Low priority). I understand the windows scheduler will allocate all available cpu resources to a process if no other processes are ready to run. However, I need to limit the cpu usage for my subprocess to a certain percentage of the cpu to 1) reduce cpu temperature, and 2) maintain responsiveness for other applications.
There are a number of freeware utilities that do this like ThreadMaster, AppSense, and various others, but I would rather be able to set cpu usage limits within my application.
My question is, does anybody know how apps like ThreadMaster do it?
Any help would be appreciated.
thanks
|
|
|
|
|
I would take a look at the SetPriorityClass function. For finer grained control, you could also consider enumerating the threads in the process, and using SetThreadPriority to drop the priority of those threads. You could also call SuspendThread and ResumeThread periodically (passing in a thread id of your child process) to further reduce the workload.
|
|
|
|
|
|
Thanks Graham. I thought I had gone the suspend/resume route last week, but I tried so many things, it's all kind of fuzzy right now.
I tried it again this morning, and it seems that if you 1) set the priority class to IDLE_PRIORITY_CLASS, and 2) do the suspend/resume dance every second, you can achieve the desired cpu usage percentage cap.
Example:
CreateProcess(args...) // priority= CREATE_SUSPENDED
SetPriorityClass(procInfo.hProcess, IDLE_PRIORITY_CLASS);
int cap = 60; // cap at 60% usage
int run = cap * 10; // run for 600 ms
int idle = (100 - cap) * 10; // suspend for 400 ms
bool isdone = false;
while (! isdone) {
ResumeThread(procInfo.hThread);
// need better handling to determine when process is complete
isdone = ::WaitForSingleObject(procInfo.hProcess, run) != WAIT_TIMEOUT;
if (! isdone) {
SuspendThread(procInfo.hThread);
isdone = ::WaitForSingleObject(procInfo.hProcess, idle) != WAIT_TIMEOUT;
}
}
The above code snippet seems to work fine without any adverse effects on the running process.
Thanks to all who replied.
mb
|
|
|
|
|
My problem is:
I need to retieve the informations of users of a Windows Server in order to my application. By this moment, my app has a Database (MS-ACCESS) with a Users Table to access to App and I want to use the database from a Windows Server. By this way when a user has log in a system don't need to log to my app.
Can anybody help me?
thaks a lot
Xavier
|
|
|
|
|
ivax wrote:
I need to retieve the informations of users of a Windows Server in order to my application.
I don't quite understand your question, but perhaps I can speculate and offer these:
NetUserEnum()
NetUserGetGroups()
NetUserGetLocalGroups()
NetUserGetInfo()
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks David.
Mu propose is retrieve UserId, Name and Password, Insert them in my Table. When a User Login in a Server I want to use the User Id And PWD in order to login in my app.
For example: A user is logged in a the Windows Server like UserId = IVAX and PWD = MYPwd.
If this User want to login in my app then he must enter again one valid UserId and PWD defined in my Database (MS-ACCESS).
My porpouse is use the User information from Windows Server Database in My application adding in my Table Users other information more.
Thanks again
Xavier
|
|
|
|
|
To my knowledge, there is no way to obtain the password that was used to login to the machine (that's not to say that a way does not exist). The user id is easily obtainable.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You can't user's passwords at all. See Raymond Chen's blog[^] for a detailed explaination of why not.
|
|
|
|
|
I'm a newbee with MFC. I'm following this article on Worker Threads:
http://www.codeproject.com/threads/usingworkerthreads.asp[^]
With the following code I'm getting the following error. Any suggestions as to what is going on here?
: error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'void (void)'
<br />
<br />
#include "stdafx.h"<br />
#include "canmon.h"<br />
#include "getcanmessages.h"<br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
static UINT run(LPVOID p);<br />
void run();<br />
volatile BOOL running;<br />
<br />
Cgetcanmessages::Cgetcanmessages()<br />
{<br />
}<br />
Cgetcanmessages::~Cgetcanmessages()<br />
{<br />
}<br />
void Cgetcanmessages::gogetcan()<br />
{<br />
running = TRUE;<br />
AfxBeginThread(run, this);
}<br />
<br />
UINT Cgetcanmessages::run(LPVOID p)<br />
{<br />
Cgetcanmessages * me = (Cgetcanmessages *)p;<br />
me->run();<br />
return 0;<br />
}<br />
<br />
void Cgetcanmessages::run()<br />
{<br />
}<br />
<br />
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Freddie Code wrote:
static UINT run(LPVOID p);
void run();
volatile BOOL running;
I suggest you rename the second function above. There are two functions named run(). One is UINT run(LPVOID) and the other is void run().
Rename the void run() to anything else because the compiler is getting confused.
this is this.
|
|
|
|
|
Why does the following code, when running, causes some programs to hang while starting (before presenting any UI), including Windows Explorer/Internet Explorer (when double-clicking an HTML file in Windows Explorer) and the AnalogX PacketMon installer[^]?
#include <iostream>
#include <tchar.h>
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
HWND gWnd = CreateWindow(_T("STATIC"), _T("SomeWindow"), WS_POPUP, 20, 20, 200, 200, 0, 0, 0, 0);
getchar();
return 0;
}
|
|
|
|
|
Why are you trying to create a GUI component in a console application?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|