|
Michael Dunn wrote: That has to be a joke.
thats the great mistake i have done!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
But why great mistake?;);P
|
|
|
|
|
sidkraft wrote: However, when one declares a variable as a CString, and uses the same utility...
And why in the world would you want to do that?
sidkraft wrote: Are there other C++ or visual C++ 6.0 utilities to work with CString variables?
They are called methods, and CString has plenty of them.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
im following this article here not quite getting it to work
http://www.codeproject.com/internet/beginningtcp_cpp.asp
Listening for connection code:
int ListenOnPort(int portno, HWND hwnd)
{
SOCKET s;
WSADATA w;
int error = WSAStartup (0x0202, &w); // Fill in WSA info
if (error)
{
return false; //For some reason we couldn't start Winsock
}
if (w.wVersion != 0x0202) //Wrong Winsock version?
{
WSACleanup ();
return false;
}
SOCKADDR_IN addr; // The address structure for a TCP socket
addr.sin_family = AF_INET; // Address family
addr.sin_port = htons (portno); // Assign port to this socket
//Accept a connection from any IP using INADDR_ANY
//You could pass inet_addr("0.0.0.0") instead to accomplish the
//same thing. If you want only to watch for a connection from a
//specific IP, specify that //instead.
addr.sin_addr.s_addr = htonl (INADDR_ANY);
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // Create socket
if (s == INVALID_SOCKET)
{
return false; //Don't continue if we couldn't create a //socket!!
}
if (bind(s, (LPSOCKADDR)&addr, sizeof(addr)) == SOCKET_ERROR)
{
//We couldn't bind (this will happen if you try to bind to the same
//socket more than once)
return false;
}
//Now we can start listening (allowing as many connections as possible to
//be made at the same time using SOMAXCONN). You could specify any
//integer value equal to or lesser than SOMAXCONN instead for custom
//purposes). The function will not //return until a connection request is
//made
int tempi = listen(s, SOMAXCONN);
WSAAsyncSelect (s, hwnd, MY_MESSAGE_NOTIFICATION, (FD_ACCEPT | FD_CONNECT |FD_READ | FD_CLOSE));
//Don't forget to clean up with CloseConnection()!
closesocket(s);
::MessageBox(NULL,"Done Listening ", "Got Request..", MB_OK);
}
//--------------
Look out for the events code:
switch (message)
{
case MY_MESSAGE_NOTIFICATION: //Is a message being sent?
{
switch (lParam) //If so, which one is it?
{
case FD_ACCEPT:
::MessageBox(NULL,"Done Listening Event", "Got Request..", MB_OK);
//Connection request was made
break;
case FD_CONNECT:
::MessageBox(NULL,"Done Listening Event", "Got Request..", MB_OK);
//Connection was made successfully
break;
case FD_READ:
//Incoming data; get ready to receive
break;
case FD_CLOSE:
//Lost the connection
::MessageBox(NULL,"Done Listening Event", "Got Request..", MB_OK);
break;
}
}
break;
case WM_KEYDOWN:
ListenOnPort(888, hWnd);
break;
..
the problem is i dont' seem to be getting any of these events FD_ACCEPT | FD_CONNECT |FD_READ | FD_CLOSE
|
|
|
|
|
You won't get any messages if you close the socket before doing
anything with it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If I have many projects that use the same MFC extension libraries, how can I set up the preprocessor stuff in each projects stdafx.h file to point to a common location for the .lib, .dll, and .h files?
For instance, this is what I'm trying but it's not quite as nice and tidy as I'd hope and I'm not sure how to direct the project to the .dll's using some similar approach.
// Class includes
#include "..\\..\\Lib\\SomeLib1\\class1.h"
// Library Stuff
#ifdef _DEBUG
#pragma comment(lib, "..\\..\\Lib\\SomeLib1\\Debug\\SomeLib1.lib")
#else
#pragma comment(lib, "..\\..\\Lib\\SomeLib1\\Release\\SomeLib1.lib")
#endif
|
|
|
|
|
I have 3 or more CSV files for each day saved in folder by each Month (September). When I open them for view as XLS it carry Master Data sheet. You can recognize the files for each day in the folder by date as following:-
abc_xyz1.xx.20070901
abc_xyz2.xx.20070901
abc_xyz3.xx.20070901 ..........so on
abc_xyz1.xx.20070902
abc_xyz2.xx.20070902
abc_xyz3.xx.20070902 ..........so on
abc_xyz1.xx.20070903
abc_xyz2.xx.20070903
abc_xyz3.xx.20070903 ..........so on
I want a Macro to open 1st csv file for that date & bring 2nd, 3rd ………files data to my 1st csv file by Adding sheet into 1st file & save the file with 1st file name.
So that when I open these file for that day I have all data into one file with multiple sheet.
I don’t know VBA at all, Please let me know if any one can help, it very urgent.
Thanks
|
|
|
|
|
So, is this a C++ question or you don't know how to program?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
jsmotu wrote: I don’t know VBA at all
Just as well you're asking in a Visual C forum then! Just code up an quick application in C to do it. No need to use VBA at all!
More seriously, there's a unix command / applet called join which should help you. Just do a google search for "join.exe win32", and you should be deluged with options.
Iain.
|
|
|
|
|
how would i attach a bitmap image to a code source for a main program. Like if i wanted to add a bitmap to load with this program :
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
You can add a bitmap to the EXE's resources or it can be in a
stand-alone file.
Which method are you interested in?
Also, how is the code you posted relevant?
Are you wondering where in the code to do the load?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think if he used of dll file for enter bitmap is better than exe file(for size of exe file).
|
|
|
|
|
Yeah. IMO that's a matter of implementation need/choice. Pretty much the same
amount of data gets added to the overall solution. The DLL will need to be loaded
eventually but I suppose if startup performance was a real issue...
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes where in the code to load it, and how would i phrase if for my C++ compiler to pull it up in the app window?
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
If you want to eneter bitmap on the resource then you can use of CBitmap::Load for load it.
|
|
|
|
|
So you want to load it and display it?
Loading can be done any time, usually before whe window that will
display the bitmap gets its first WM_PAINT message.
Displaying should be done in response to WM_PAINT.
How you load the bitmap depends on where it's stored and what format it's in.
Displaying the bitmap depends on what format you load it in.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I dont know is this your question you can enter code of bitamp on the source code of your project.
|
|
|
|
|
Really i need the starting of the script to add the bitmap and to know where to add it to the exe file format. But the information given already give me and idea. < might be a bad idea but worth a try>
Hamid. wrote: I dont know is this your question you can enter code of bitamp on the source code of your project
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
You can import bitmap file to resource of exe file but here a problem that it increase size of exe file but you can load bmp of a foreign file but it depends to your program after select way if you have any question you can ask of me.;)(but I dont know why I got vote 1 on previous reply)
|
|
|
|
|
In my opinion, C++ was one of the best languages
ever developed, with perhaps the exception
of Forth, but, my recent experience
with the VC++, has left me wishing that
there was some intergalactic force that
would bring justice to the MS clan.....
LFI4DST
|
|
|
|
|
I agree. Now please give me a link to your solution that is superior so I can start using it.
|
|
|
|
|
|
essentially, in the early 90's C++ was standardized
over most platforms - closely enough that going
from one compiler to the next was a reasonable
option and C++ resources worked fairly uniformly -
There is so much unique to .net now ( and I'm
still not really sure what that it )
and so much unique to the environment that
it's hard to know - what is right and
wrong - as far as approaches to problem
solving ------
It's more of a personal thing I think sort of
a nostalgia mostly -
I mean in the 90's there were still people
around who thought that C++ was a mistake -
and that C was really the best way to go ....
But - it's about writting code - that can
hang in there ....
I mean - there's also the group that says -
heh ------- we don't need no stinking C++
because Java is okay for everthing -
It's really mostly nostalgia .....
|
|
|
|
|
|
Hamid. wrote: And your question?
is still a question?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|