|
Yes, the dialog resource is available in one of the main system DLLs. I've seen it before but can't remember which file it's in. Why not just make your own? It'll take all of five minutes.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a cancel dialog for an operation that takes a while. The problem is when, in the loop, I try to change a Static control's text on the cancel dialog, it doesn't seem to erase its background (if it's showing a long file name and then a short one, the end part of the long one is still showing). I found workarounds like calling InvalidateRect on the parent dialog, but it causes a lot of flickering... I'm using the following code to process messages while in the loop:
<code>
MSG msg;
while (PeekMessage((LPMSG) &msg, (HWND) NULL, 0, 0, PM_REMOVE))
{
if (!IsDialogMessage(m_hDlgWnd, (LPMSG) &msg))
{
TranslateMessage((LPMSG) &msg);
DispatchMessage((LPMSG) &msg);
}
}
</code>
Is there anything i'm missing?
(I'm not using MFC or anything)
- thanks
|
|
|
|
|
Why not invalidate the static control itself.
After setting the new text you want.
|
|
|
|
|
Blake V. Miller wrote:
Why not invalidate the static control itself.
that was one of the first things I tried - didn't work
|
|
|
|
|
How i can insert data into ListCtrl when i clicked on TreeCtrl item
it doesn't work true with me
plz help me
|
|
|
|
|
Well, how are you trying to do it now ? Are you saying the data comes from the clicked treectrl item ? What's going wrong ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
When i clicked on TreeCtrl item that came from the database then the ListCtrl make a query for this data and appear it on the ListCtrl
so if u want the project take my email
m_fuad67@hotmail.com
MFC programmer
|
|
|
|
|
m_fuad67 wrote:
When i clicked on TreeCtrl item that came from the database then the ListCtrl make a query for this data and appear it on the ListCtrl
So which bit are you stuck on ? Can you set the selected item ? Run the SQL ? Get the data to put in the list ?
m_fuad67 wrote:
so if u want the project take my email
Not really, I'd rather you asked more specific questions, so everyone here can try to help you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Please help me How can i use (dbf) FoxPro files with MFC. I want to open data from dbf file..
|
|
|
|
|
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
|
|
|
|