|
Is this an MFC program? I put these lines at the very beginning of the InitInstance function and it worked ok.
CString something;
int x = something.LoadString(ID_FILE_SAVE_AS);
MessageBox(NULL,something,"",MB_OK);
also tried this and it worked too
char buf[255];
int x = LoadString(AfxGetInstanceHandle(), ID_FILE_SAVE_AS, buf, sizeof(buf));
MessageBox(NULL,buf,"",MB_OK);
|
|
|
|
|
Yeah, I'm not sure what happened here. It started working again --- must have been some weird compiler glitch or something... ?
Thanks though!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Edits on focus calls up a dialog for entering a number, all works fine except when you CANCEL.
So I have created a cancel button:
void CNumberEntry::OnCancel()
{
CDialog::OnCancel();
idigit = 0;
sRangevalue = " ";
UpdateData(false);
EndDialog(2);
}
But after this the dialog won't pop up?
Any ideas?
Thanks.
}
|
|
|
|
|
This is some strange code.
1. What is sRangeValue and idigit? (And why don't you use the m_ prefix convention for member variables?)
2. Do you realize that CDialog::OnCancel already calls EndDialog?
3. Why do you call UpdateData(false)?
4. Does it work fine for OnOK? If so, could you post the code for OnOK?
6. Could you post the code that pops up your CNumberEntry dialog box?
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
These aren't member variables. The number entry code as posted is used as a soft keyboard. So I have to retain values as they are input so I can allow other functions such as clear and delete to remove characters.
I believe that the only reason I had to write my own cancel function is that some how I delete the OnCancel or it just wasn't working and I don't know how to get the original code back.
The OnOK function does work fine as it returns and the values are there. I don't do anything with this function in CNumberEntry as it just returns and I set the new values.
I don't know why I have the UpdateData(false)...I've tried so many thing and it has just hung around.
if(GetNumDlg.DoModal()== OnOK)
{
//number returned is sent to the host computer for update...
}
Thanks for taking the time to look at this.
Jim
|
|
|
|
|
I wish you could show the "OnSetFocus" code, where you create the dialog object and show it. If this code is being called every time you set the focus to your edit control, it should work. It doesn't make sense that it would only pop up the first time and then never again, just because you pressed Cancel. What little code you have provided so far does not show anything that would cause this behavior. That's why I must insist that you show as much as possible to see if the problem becomes evident.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
void CAMID::OnSetfocusRange()
{
CNumberEntry GetNumDlg;
static bool calleddialog; //flag to keep dialog from
if(calleddialog == 0)
{
calleddialog = 1;
int x = GetNumDlg.DoModal();
if( x== IDOK)
{
calleddialog = 0;
int iTempRangeAlong;
iTempRangeAlong = atoi(GetNumDlg.sRangevalue);
if( (iTempRangeAlong < 2000) && (iTempRangeAlong >= 0) )
{
TStruct.IOSRequest.bIOSRA = TRUE;
TStruct.IOSRequest.iIOSRA = iTempRangeAlong;
wtxMemWrite(wtxh,&TStruct.IOSRequest.bIOSRA,tstructaddress
+ ((int)&TStruct.IOSRequest.bIOSRA
- (int)&TStruct), sizeof(bool));
swapLong((char*)&TStruct.IOSRequest.iIOSRA);
wtxMemWrite
(wtxh,&TStruct.IOSRequest.iIOSRA,tstructaddress
+ ((int)&TStruct.IOSRequest.iIOSRA
- (int)&TStruct), sizeof(int));
}
CEdit* pNextField = (CEdit*)GetDlgItem(IDC_STATIC);
pNextField->SetFocus();
}
}
this is it...sorry about the formating...this thing really has a mind of its own.
Thanks for hanging in there...I've got lots to learn!
|
|
|
|
|
Sorry I haven't back to you on this. From the code it appears as though the culprit is your "calleddialog" variable. When DoModal returns IDOK, it gets reset to false , but when it returns IDCANCEL, it remains true and your code no longer gets executed.
Remember that DoModal does not return until the user closes the dialog, so you shouldn't need to worry about this code being executed again while the dialog is up. In other words, get rid of the "calleddialog" flag. If this code can indeed be called again while the dialog is up, the most likely reason is that the dialog does not have a proper parent window. Construct it like this:
CNumberEntry GetNumDlg(this);
This tells it to use the current dialog as the parent window thereby disabling it when it comes up.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks Alvaro, I'll look into this tomorrow when I'm back at work.
Thanks!
|
|
|
|
|
Hi! I have problems with onidle methods that take up 100% of the processor. If I overload the OnIdle method in the main class of my application, without anything in it:
BOOL CtestApp::OnIdle(LONG lCount) {
return TRUE;
}
than after the application starts it eats all the processor. In Windows task manager the CPU Usage is 100%. But if I start using the application (click through the menu, etc) the CPU Usage drops to 10-20 or even lower.
What can I do? I removed the OnIdle method from the main class but I need an OnIdle method in a socket class to receive the messeges as they arrive from the server.
The OnIdle method is started like this: AfxBeginThread(OnIdle2,0);
and it looks like this
UINT OnIdle2(LPVOID pParam) {
int z;
DWORD dwWaitResult;
sockArray[0] = globalSocketHandler;
int wMsg = 190190;
while (OnIdleContinue) {
dwWaitResult = WaitForMultipleObjects(1,sockArray,TRUE,10);
z = WSAAsyncSelect(theApp.socket.GetSock(),AfxGetApp()->GetMainWnd()->GetSafeHwnd(),wMsg,FD_READ);
switch (dwWaitResult) {
case WAIT_OBJECT_0:
//read
strcpy(theApp.socket.buff,"");
theApp.socket.ReadMsg();
break;
default:
TRACE("nothing\n");
//nothing;
break;
}
}
return 1;
}
Thank you for any suggestion.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
If you return a non-zero value from OnIdle you are asking for more idle processing time ( and you will get it ).Return 0 if you don't need more.
|
|
|
|
|
This is a bit of a long subject but you might consider listening to your socket in a seperate thread instead of using the OnIdle override. Functionally, it's probably easier to manage using the onidle, but I think a multithreaded solution would give you much more flexibility.
Paul
|
|
|
|
|
My OnIdle function it was actually a separate thread, not an override of the OnIdle function. I fixed the problem. It seems that the function waitformultipleobjects did this.
Now my function does just a repetead read on the socket and if there is a message than it processes it.
Thanks for the help.
A Happy New Year!
Florin
|
|
|
|
|
I'm trying to simulate a multiprocess job with the use of semaphores, but I'm not fluent in C++. Anybody knows how to implement such thread controls?
|
|
|
|
|
The C++ standard does not cover multithreading. If you want to implement multithreaded apps you will have to use platform specific routines - for windows look in MSDN for synchronization functions ( InitializeCriticalSection, CreateMutex, CreateSemaphore, etc). One of the best samples of how to use them is MFC - look in the implementation of CMutex , CSemaphore, and the rest of synchronization classes.
|
|
|
|
|
I am writting a windows application that uses Namepipes for IPC. I have a strange problem which is that this IPC some times fails in a random way. It will work just fine for some time and then suddenly will thow an exception saying that the namepipe initiator is expecting for the other end to open the pipe. The main issue is that this behavior is random and so far there is no way to repeat the error when I want it. I would appreciate any ideas for handling this issue. Thank you in advance for your time.
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
I'm trying to set the button text on the fly so that it can change labels as things change in my app.
I have been unable to figure out how/what type of var will work.
I've tried an array of char, a pointer, but it seem to only work when I use "blah....".
Is there a way? Maybe I just need some more coffee
|
|
|
|
|
DOUGH! I got it...seems in my attempt at this I left the button definition where it was...later in the program!
That coffee really works!
Thanks for looking
|
|
|
|
|
SetDlgItemText(....)
try.
|
|
|
|
|
hi,
I am using a system wide hook and get the handle (HWND) of the process about to start. How do I get the filename from this handle?
i am running win98,nt,2000,xp
thanks
neil
|
|
|
|
|
If you have the window handle you can use GetWindowThreadProcessId to get the process id , then using PSAPI or ToolHelp lib you can get the file name.
|
|
|
|
|
I have vc++ .net and I have a project that has a single define for compiling certain code for U.S. users and other code for Canadian users.
What I want to do is build two releases at the same time from the same code with one being built with the define BUILDCANADA defined and the other not, but I don't want to have two separate projects.
I see lot's of info on doing simultaneous separate builds based on compiler settings etc, but nothing that shows if it's possible to do one build with a define set and another with it not set. I guess what the real question is, is can you set a DEFINE in the build options somewhere?
|
|
|
|
|
Go into the "Build" menu, click on "Configuration Manager", here you can make multible configurations.
Then you can go into th projects options, and define what you need for each configuration.
To build both projects in a single step, select "Batch Build..." in the "build" menu...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi Anders, thanks for replying. I know you can do that, but the critical thing is that I need to have a DEFINE set differently for the two builds, is that possible?
|
|
|
|
|
In "Configuration dialog|C/C++|Preproccesor", there is an option called "Preprocessor definitions" where you can define your BUILDCANADA or whatever you want.
--------
Dave
|
|
|
|