|
Hello,
<br />
#include "B.h"<br />
class A<br />
{<br />
public:<br />
B m_BClass;<br />
<br />
void SayHelloToMyLittleFriend() {}<br />
};<br />
<br />
class A;<br />
class B<br />
{<br />
public:<br />
A* m_pAClass;
<br />
void LetsRock();<br />
};<br />
<br />
#include "B.h"<br />
#include "A.h"<br />
<br />
void B::LetsRock()<br />
{<br />
<br />
m_pAClass->SayHelloToMyLittleFriend();<br />
}<br />
|
|
|
|
|
nice work mate!
Yours Truly, The One and Only!
|
|
|
|
|
what if I do not have an implementation file (cpp) because I wanna keep the code in the header? does it work, too? Or do I have to ship everything into an implementation file?
|
|
|
|
|
that should not matter if you put everything into a header file, but in most cases you will want to separate declaration with implementation! .... people just want to see the class members and know how to call it, they don't care how it's implemented and having to read tons of line of code figure out all your methods in a class is not the way to code.
if you want to declare everything inside the head file you have to make all the method inline, otherwise you're going to get linking errors.
i.e
class A {
public:
void MyFunc() {
}
};
void A::MyFunc() {
}
I am sure you will figure it out
Yours Truly, The One and Only!
|
|
|
|
|
i have tried to draw image on non client area(glass effect) in windows vista aero glass view with GDI+ in MFC (included alpha channel) as suggested in one of previous article. but image gets invisible there because when i write the same code in xp it draws the image in non client area. what could be the reason for it?
|
|
|
|
|
Hi,
Windows explorer uses soem icons(bitmaps) for folder, New Folder, Delete etc. Are those standard icons? Can we use same icons in my application? If yes what are the ID's of those icon? Can I load them using LoadResource(), or LoadBitmap() function?
Regards,
Hemant
|
|
|
|
|
some programs like "irfanview" can load icons of apps.
simply drag the app into irfan view and you get the icon.
search your windows and windows\system folder for *.dll they should be contained in some
|
|
|
|
|
The shell32.dll is one of them, I believe. This contains a lot of major ones, although others are in other places.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Alot of similar icons/bitmaps are included with Visual Studio.
You can also open any exe or dll in visual studio and copy resources right to your projects.
Whether it's legal to use them or not, I'd say it's not legal without permission. At the same
time, Microsoft wants us to have consistent user interfaces
I'm not a lawyer...you're on your own there.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The older MSDN documentation for UuidCreate() lists some return values that indicate the global uniqueness of the id depending on the presence of an ethernet/token ring address.
RPC_S_OK
RPC_S_UUID_LOCAL_ONLY
RPC_S_UUID_NO_ADDRESS
However, the newer MSDN documentation throws in a statement...
"For security reasons, UuidCreate was modified so that it no longer uses a machine's MAC address to generate UUIDs"
Does this mean that UuidCreate() function will now always return RPC_S_OK ?
|
|
|
|
|
what does the latest msdn say about return values, that would be your answer!
Yours Truly, The One and Only!
|
|
|
|
|
"For security reasons, it is often desirable to keep ethernet/token ring addresses on networks from
becoming available outside a company or organization. The UuidCreate function generates a UUID that
cannot be traced to the ethernet/token ring address of the computer on which it was generated. It
also cannot be associated with other UUIDs created on the same computer. If you do not need this
level of security, your application can use the UuidCreateSequential function, which behaves exactly
as the UuidCreate function does on all other versions of the operating system."
"In Windows NT 4.0, Windows Me/98, and Windows 95 DCOM release, UuidCreate returns
RPC_S_UUID_LOCAL_ONLY when the originating computer does not have an ethernet/token ring (IEEE 802.x)
address. In this case, the generated UUID is a valid identifier, and is guaranteed to be unique among
all UUIDs generated on the computer. However, the possibility exists that another computer without an
ethernet/token ring address generated the identical UUID. Therefore you should never use this UUID
to identify an object that is not strictly local to your computer. Computers with ethernet/token ring
addresses generate UUIDs that are guaranteed to be globally unique."
UuidCreate[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The MAC address is used as part of the UUID. AFAIK it still is - that's how global uniqueness is guaranteed - it just doesn't appear in plaintext in the UUID anymore.
|
|
|
|
|
My project is about using keyboard for control the sound.
such as if the user key in "a", the program should talk to the user that he\she is pressing "a" button.I use KeyBoard hook for trap the message and send the message to main program, My code in main windows as
LRESULT CKeySoundDlg:rocesskey(WPARAM w, LPARAM l)
{
if (w==(WPARAM)VK_ESCAPE)
{
strBuf = "C:\\KeySound by Hi-Speed2007\\Esc.wav";
PlaySound();
}
if (w==(WPARAM)VK_F1)
{
strBuf = "C:\\KeySound by Hi-Speed2007\\F1.wav";
PlaySound();
}
return 0L;
}
void CKeySoundDlg::PlaySound()
{
m_cSound.SetCommand("Close");
m_cSound.SetFileName(strBuf);
m_cSound.SetCommand("Open");
m_cSound.SetCommand("Play");
}
But my keyboard have 2 language(English and Thai),So I need to check the key board mode, Is it in English or Thai mode.
My problem is that, how can I separate language of keyboard.
How to know, right now user key in English or Thai.
Thanks
Max
-- modified at 23:06 Friday 27th July, 2007
|
|
|
|
|
If you need it system wide, you'd need a Keyboard hook to trap the keys. Then for making your application "talk", you can use the microsoft TTS. Search for it.
Max++ wrote: how can I separate language of key board.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
Right Now I use keyboard hook but I don't know how can I translate the virtual-key code to character in Thai language.
|
|
|
|
|
I've never heard of anyone separating a language before, either.
Maybe though, some users regularly remove all the text on their keyboard, put new things on, and expect that the key will do the different thing.
I would re-cover it so the first five letters on row one were "B R O K E".
Instead of QWERTY, we can say "it's a Broke keyboard".
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Hi Everybody.
I am currently trying to establish a connection between two computer linked with a Wifi network (ad hoc network). For that I tried to use Winsock2 but it didn't work as well as when I use it with LAN.
Could somebody help me please?
Thanks in advance.
Here is the code implemented for the server
<br />
#include "stdafx.h"<br />
#include "IAMNet.h"<br />
#include <winsock2.h><br />
#pragma comment(lib, "ws2_32.lib")<br />
<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
<br />
CWinApp theApp;<br />
<br />
using namespace std;<br />
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{<br />
int nRetCode = 0;<br />
<br />
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))<br />
{<br />
_tprintf(_T("Erreur irrécupérable : l'initialisation MFC a échoué\n"));<br />
nRetCode = 1;<br />
}<br />
else<br />
{<br />
WSADATA WSAData;<br />
SOCKET sock;<br />
SOCKADDR_IN clientsin;<br />
SOCKET csock;<br />
SOCKADDR_IN sin;<br />
SOCKADDR_IN csin;<br />
CHAR buff;<br />
WSAStartup(MAKEWORD(2,0), &WSAData);<br />
<br />
cout<<"hello\n\r";<br />
<br />
sin.sin_addr.s_addr = INADDR_ANY;<br />
sin.sin_family = AF_INET;<br />
sin.sin_port = htons(50014);<br />
sock = socket(AF_INET,SOCK_STREAM,0);<br />
bind(sock, (SOCKADDR *)&sin, sizeof(sin));<br />
gethostname(&buff, sizeof(buff));<br />
listen(sock, 0);<br />
<br />
int val = 0;<br />
<br />
while(1)<br />
{<br />
int sinsize = sizeof(csin);<br />
if((csock = accept(sock, (SOCKADDR *)&csin, &sinsize)) != INVALID_SOCKET)<br />
{<br />
<br />
int size = sizeof(clientsin);<br />
int succes = getpeername(csock,(SOCKADDR *)&clientsin, &size);<br />
int a = WSAGetLastError();<br />
<br />
send(csock, "Hello world!\r\n", 30, 0);<br />
cout<<"client connected \n\r";<br />
}<br />
}<br />
}<br />
<br />
return nRetCode;}<br />
<br />
}
Here is the code implemented for the client
<br />
<br />
#include "stdafx.h"<br />
#include "iamclient.h"<br />
#include <winsock2.h><br />
#pragma comment(lib, "ws2_32.lib")<br />
<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
<br />
CWinApp theApp;<br />
<br />
using namespace std;<br />
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{<br />
int nRetCode = 0;<br />
<br />
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))<br />
{<br />
_tprintf(_T("Erreur irrécupérable : l'initialisation MFC a échoué\n"));<br />
nRetCode = 1;<br />
}<br />
else<br />
{<br />
WSADATA WSAData;<br />
WSAStartup(MAKEWORD(2,0), &WSAData); <br />
SOCKET sock;<br />
SOCKADDR_IN sin;<br />
char *buff = new char[255];<br />
sin.sin_addr.s_addr = inet_addr("180.0.0.2");<br />
sin.sin_family = AF_INET;<br />
sin.sin_port = htons(4148);<br />
sock = socket(AF_INET,SOCK_STREAM,0);<br />
bind(sock, (SOCKADDR *)&sin, sizeof(sin));<br />
connect(sock, (SOCKADDR *)&sin, sizeof(sin));<br />
while(1)<br />
{<br />
recv(sock, buff, sizeof(buff),0);<br />
cout<<buff;<br />
}<br />
}<br />
<br />
return nRetCode;<br />
}
djin94
|
|
|
|
|
djin94 wrote: Could somebody help me please?
Help to do what ? What does not work ? Does the application crash ? Have you tried and debug it ?
Faut un peu nous aider à t'aider...
|
|
|
|
|
What's not working?
Is this a networking question or a programming question?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I didn't look at your code because I think there is a problem with your approach to analyzing your issue. You are doing two different things so simplify that by doing just one at a time. You can test socket code on one machine without any network connection at all. Also you can test your ad hoc network configuration by using freely available socket applications rather than your code. Prove that each works independent of the other before integrating them.
|
|
|
|
|
Hi!
Finally I managed to make it work, it was a problem with the IP adress of both computers which were not good. I changed these IP adress to new ones which were corresponding to private IP adress and it works well now.
Thanks everybody for your answers.
|
|
|
|
|
Use the same port number for both client and the server.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
It has been a week i am working on a programme that read .txt files. If one of those file has the same beginning that a model file ( except the first line) then the programme has to rename the file.This part of the programme works.
The thing is thatthe names of files that must be compared to the modele file change every day. Therefore, i use a programme which lists every file in the directory in a txt file.
Then i read the listfile and assign to a string each name of file and compare those files to the modele file. However, althaug i spend hours and hours on this programm, i still have problems... can anyone help me by having a look at the programme... i can send the programme, modele file, the programme to list every file in a directory, and files that must be compared.
Thank you very much in advance!!
|
|
|
|
|
Do you use the debugger to find your problems?
I'd suggest you do so and try to localize whatever issues you have. Then you can post some source code so the rest of us can help. You probably won't have much success finding someone to take your program and test it for you.
|
|
|
|
|