|
Hello, the codegurus around the world.;)
The other way is that you create only one OnSelChange(), and assign this
function inside the message map. That is, all five ComboBoxes share one
OnSelChange(). (Or create your own function associated the message)
And, we can check which ComboBox get the input focus when this message
is checked.
I guess that this works.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hello, i am trying to begin in Win32 programing and wondering where some good win32 resources are to help begin in it (not books). And if you know a really good book on it please let me know, although im primarly looking for web (free resources) since i dont have $60+ to shell out.
Also MFC but i think its a good idea to learn win32 before mfc.
|
|
|
|
|
I don't think it's so great to learn Win32 first, I found it better to go back and learn Win32, now I appreciate all the ways MFC made it easy to learn by simplifying tasks. A bit like Stroustrup saying you should learn C++ before C ( not that I've ever done C ).
However, THE Win32 reference is Programming Windows by Charles Petzhold. You'll have trouble finding much on Win32 on the web, it's 99.99% MFC. I know, because we're not using MFC in our current project, and my only sources of info are MSDN, Petzhold and asking questions here. Not many articles are helpful because they all use MFC.
Windows Developers Journal is a good source of Win32 info, they rarely print MFC articles, except in their annual MFC issue.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I use a CSocket derived class with a derived CWinThread class and use CArchive with it. For some yet unknown reason Send() locks after a while of running (hours). The opened socket has communication initiated from both client and server at times, if that helps. (Server sends tiny data once per second, client sends kB data occasionally, like every 10 seconds or so, plus both sides sends an ACK byte for every command)
Anyway, since I cannot find the reason of the locking, I want to get around the locked state. I want to make something from the outside and would like to have an OnIdle timer reset at intervals in the CWinThread. A parent thread will check this timer and if it isn't reset in reasonable time (seconds) the parent thread will call CancelBlockingCall() on the locked socket.
Now, will this work? Isn't it illegal to call the CSocket object function from another thread?
|
|
|
|
|
From my own experience CSockets simply aren't reliable enough for programs that need to run continuously. The best "workaround" is to use Winsock2 API directly. In my own project, I wrote a "wrapper" class to provide a CSocket-style interface so I didn't have to change the main code too much.
|
|
|
|
|
*shrug*, yes, I've read this before... if I could only understand why it's locking I think we could use CSocket. We do use it in similar applications that doesn't communicate so much.
|
|
|
|
|
I know wireless is a big topic these days, so this might interest some of you. To send SMS wireless messages to cell phones and pagers from a variety of Visual C++ applications, you might want to try our company Simplewire. There is a Developer Program at http://devprogram.simplewire.com or just go to http://www.simplewire.com.
We have SMS Software Development Kits in many versions, including a very easy to use ActiveX version. The ActiveX SMS SDK will run inside ASP pages, Visual C++ Projects, Internet Explorer, Visual Basic, Delphi, Powerbuilder, Microsoft Office, or any other environment that support ActiveX COM objects.
Then you can use Simplewire's network to connect to hundreds of networks. Hope this may help some of you who are looking to get into wireless. The Developer Program is completely free, so feel free to try it.
I've included a little source code so you can get a feel for how things embed into your app with the component.
#include <iostream.h>
#import "SimplewireSMS.tlb"
int main(int argc, char* argv[])
{
// Initialize COM
CoInitialize(NULL);
// Instantiate SMS Object
Simplewire::ISMSPtr pISMS;
pISMS.CreateInstance("Simplewire.SMS");
// Subscriber Settings
pISMS->PutSubscriberID("123-456-789-12345");
pISMS->PutSubscriberPassword("Password Goes Here");
// Message Settings
pISMS->PutMsgPin("+1 100 510 1234");
pISMS->PutMsgFrom("Demo");
pISMS->PutMsgCallback("+1 100 555 1212");
pISMS->PutMsgText("Hello World From Simplewire!");
// Send Message
cout << "Sending message to Simplewire..." << endl;
pISMS->MsgSend();
// Check For Errors
if(pISMS->GetSuccess())
{
cout << "Message was sent!" << endl;
}
else
{
cout << "Message was not sent!" << endl;
cout << "Error Code: " << pISMS->GetErrorCode() << endl;
cout << "Error Desc: " << pISMS->GetErrorDesc() << endl;
}
// Cleanup
pISMS.Release();
CoUninitialize();
return 0;
}
Hoping this helps!
Bob
|
|
|
|
|
How to rebuild icons cache in WIN98?
|
|
|
|
|
Can I use into ATL project in dll that I wrote in mfc (by attach the lib file and the header file of that to the ATL project) ?
So that my ATL will import functions from this mfc dll.
because I need to provide this dll for delphi and I dont know how to write all this project in ATL .
So the dll that will get from this ATL will be wrap to the mfc dll.;)
What do you say , Christian Graus
|
|
|
|
|
Yes, but when you are creating the ATL Project you need to check MFC Support....
You will have no problem with that.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
|
Don't mention it....
We are for help you...
Carlos Antollini.
|
|
|
|
|
Well, I want to use my mfc dll <mydll> in ATL .I do so :
1. open project: ATL COM Wizard.<myatl> [DLL] [MFC Support]
2. insert to the library that created the file : MyDll.dll
and attach to the ATL project the files : MyDll.h , MyDll.lib
-----------------------------------------------------------------
now I want to insert to my ATL the bellow code lines (such as I maked successfully at mfc client program):
#include "MyDll.h"
extern __declspec(dllexport)int func(LPSTR str)
{
MyDialogObject dlg;
dlg.DoModal();
.............
.............
}
--------------------------------------------------------------------
Is this the right way to write it in the ATL ?
Where have I put that code ?(In the cpp file ?)
--------------------------------------------------------------------
I wiil be greatful if you will answer me .
|
|
|
|
|
In your ATL DLL project,
Insert->New Class
ClassType = ATLClass
Name = CMyDialogWrapper
InterfaceType = Dual
NumberOfInterfaces = 1
Hit OK
In ClassView find the IMyDialogWrapper under CMyDialogWrapper
Right mouse, AddMethod
MethodName ShowDialog
Hit OK
In the generated function
STDMETHODIMP CMyClassWrapper::ShowDialog()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
m_dlg.DoModal();
return S_OK;
}
Add m_dlg to the CMyClassWrapper class defintion
Hope this helps,
Michael
|
|
|
|
|
Thanks ! I succesed do it through your excellent tutorial !
it passed compilation succesfully !
Now I need test it .
Can you explain me how to build client program (in mfc).
Which files I need to attach?
Is it enough to write so:
------------------------------------------------------------
CMyDialogWrapper dlg;
dlg.ShowDialog();
------------------------------------------------------------
Please ! Please ! Please ! It is very urgent !!!
|
|
|
|
|
I've done a plugin based application where the core of the program is in an .exe file and the plugin engine in a .dll. The plugins themselves are on another folder (see below). Last week I made a new plugin which use the zlib.dll the read zip files.
So here's the linkage:
- .exe load plugin engine .dll
- plugin engine .dll load the unzip plugin
- the unzip plugin load the zlib.dll (this is dynamic linking)
and here are the 2 folders:
appplication.exe
plugin engine.dll
|___plugins folder with...
unzip plugin.dll (compiled with zlib.lib)
zlib.dll
Unfortunaltely I found that to make this work I have to put the zlib.dll on the application root folder.
Can someone tell me how what I should do to make this work with the zlib.dll in the plugins folder instead ?
Yarp
|
|
|
|
|
I suppose you could try to set the current directory to the plugin directory before loading a plugin DLL, then restore the previous current dir.
According to MSDN, about LoadLibrary(), the current directory is searched also, but since zlib.dll is referenced by another module and not manually loaded I'm not sure this will work.
Solution, as always, is trying
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
That's it, it works fine.
...As always simple is effective.
Thank you for the advice, it looks better that way.
Yarp
|
|
|
|
|
Whenever I run my app under windows 98 (debug build), I get a runtime error and the pleasant option of either closing the app or debugging it. I hit debug and the OS freezes.
If I run the same app under the debugger (no breakpoints), it runs fine. However, the output window does print the following message when the app has exited
First-chance exception in myapp.exe (mydll.DLL): 0xC0000005: Access Violation
Does anyone have any pointers on how I might track this one down?
James Spibey
Well cover me in honey and throw me to the lesbians!
|
|
|
|
|
Answered my own question, I'm afraid. This thread is the place to look.
James Spibey
Well cover me in honey and throw me to the lesbians!
|
|
|
|
|
Hey folks,
I'm writing some code that uses structures to define which functions to use on which data. I've written a little example here that would give you an idea of what I'm trying to do in hopes that you could point me in the right direction.
typedef BOOL (*POPULATEPROC) ( VOID* pbuffer, USHORT data );
typedef struct FIELDDATAmd
{
CHAR name[40];
USHORT width;
POPULATEPROC popproc; // Function called to initialize this field
}FIELD_DATA, *PFIELD_DATA;
FIELD_DATA My_Data ( ("Device Name, 20, Populate_Devicename ),
("Model Name, 25, Populate_Modelname ) );
Now, for each of the fields in My_Data, I have specified a function which will be used for population. I've implemented this type of thing many times in Win32 without any problems.
My_Data[2].popproc ( "text", 20 ); ( this runs my Populate_Modelname function )
Now... question is: ... If I wanted to do this in C++, how would I go about doing it?
I have a class called CTestDlg, which has a FIELD_DATA structure, which has fields and pointers to functions. How do I set this up such that the functions it points to are member functions for my CTestDlg class?
I've tried implementing it like so:
FIELD_DATA My_Data ( ("Device Name, 20, CTestDlg::Populate_Devicename ),
("Model Name, 25, CTestDlg::Populate_Modelname ) );
And no luck... anyone have any ideas?
Mike, doner@obtain.com
|
|
|
|
|
The problem is that your methods CTestDlg::Populate_Devicename and CTestDlg::Populate_Modelname are not POPULATEPROC s. The methods accept a "hidden" additional parameter, namely the this pointer. Otherwise, how could your program possibly know which CTestDlg instance to call the methods upon just from the information stored in a FIELD_DATA struct?
This question is very frequently asked here and the Mike Dunn's C++ FAQ addresses it, have a look there.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín is right. If you declare the dialog members as static to change them from __thiscall to __cdecl , then something like this will work:
#include <iostream>
#include <windows.h>
using namespace std;
typedef BOOL (*POPULATEPROC) ( char* pbuffer, USHORT data );
class CIWishIWasADialog {
public:
CIWishIWasADialog();
~CIWishIWasADialog();
static BOOL Populate_Devicename( char* pbuffer, USHORT data ) {
cout << "We're in Populate_Devicename - " << pbuffer << endl;
return TRUE;
}
static BOOL Populate_Modelname( char* pbuffer, USHORT data ) {
cout << "We're in Populate_Modelname - " << pbuffer << endl;
return TRUE;
}
};
struct FIELD_DATA
{
CHAR name[40];
USHORT width;
POPULATEPROC popproc;
};
FIELD_DATA My_Data[] = {{"Device Name", 20, CIWishIWasADialog::Populate_Devicename},
{"Model Name", 25, CIWishIWasADialog::Populate_Modelname }};
int main(int argc, char* argv[])
{
My_Data[0].popproc("Honda",0);
My_Data[1].popproc("Accord",0);
{
int x;
cin >> x;
}
return 0;
}
But now you have a bit of a problem in that the static members don't have access to other members (i.e. don't have an implicit this pointer).
Hmmm... what if you had a series of windows messages defined - like UWM_POPULATE_MODELNAME - then you could post a message to the dialog instead of calling a member directly. You could then just use the message IDs in your structs as well, and wouldn't have to worry about the dialog::function name.
|
|
|
|
|
Thanks for the info, I managed to get it to work using the C++ Faq idea..
Created a static function, I passed "this" in as one of the params, then casted it to the dlgtype... works.
Much appreciated.
Mike.
|
|
|
|
|
Lame.
I'm trying to use ShGetFolderPath to figure out the location of the "My Documents" forlder and MSDN claims that I need ShFolder.h and ShFolder.lib. Overlooking the fact that all other shell related files begin with "SHL" and not just "SH", when I included them, my compiler (VC6 no SPs) claims not to be able to locate them...
I looked for them myself and lo and behold, they are missing. I seem to have every other file, just not the one I want.
So, I have two questions:
1. Do the ShFolder.* files exist and for some god-foraken reason I don't have them or are they part of mythology?
2. Is there another API or way to find the "My Documents" folder that does not include searching the hard drive for it?
Thanks in advance,
The Arabundi
---
PAGE FAULT: Please insert "Swap File Disk 2" in drive and press any key to continue
|
|
|
|
|