Click here to Skip to main content
15,915,611 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTabStop not working when add image over a button control. Pin
Le@rner5-Apr-09 21:11
Le@rner5-Apr-09 21:11 
AnswerRe: TabStop not working when add image over a button control. Pin
Iain Clarke, Warrior Programmer5-Apr-09 22:15
Iain Clarke, Warrior Programmer5-Apr-09 22:15 
QuestionCapturing TCP/IP packets in (DOS) Pin
rbwest865-Apr-09 21:11
rbwest865-Apr-09 21:11 
AnswerRe: Capturing TCP/IP packets in (DOS) Pin
Garth J Lancaster5-Apr-09 21:37
professionalGarth J Lancaster5-Apr-09 21:37 
AnswerRe: Capturing TCP/IP packets in (DOS) Pin
Iain Clarke, Warrior Programmer5-Apr-09 22:21
Iain Clarke, Warrior Programmer5-Apr-09 22:21 
GeneralRe: Capturing TCP/IP packets in (DOS) Pin
rbwest866-Apr-09 4:47
rbwest866-Apr-09 4:47 
GeneralRe: Capturing TCP/IP packets in (DOS) Pin
Iain Clarke, Warrior Programmer6-Apr-09 6:31
Iain Clarke, Warrior Programmer6-Apr-09 6:31 
QuestionRe: Capturing TCP/IP packets in (DOS) Pin
rbwest867-Apr-09 23:40
rbwest867-Apr-09 23:40 
Ok, so I have done more reading.

I have been reading about winsocks. I due have a question. Here is the code I have been piecing together. Can someone please tell me what I am doing wrong? I get a compiling error "using Dev++" on line 105. I know I am new to programming with sockets but I need a little guidance. I am stationed in Iraq and there is no reference other than feedback from this forum. Thank you very much in advance.

Errors:
Compiler: Default compiler
Building Makefile: "C:\Users\mininet\C++\socket programming\Makefile.win"
Executing make...
make.exe -f "C:\Users\mininet\C++\socket programming\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

main.cpp:105: error: expected constructor, destructor, or type conversion before '=' token
main.cpp:105: error: expected `,' or `;' before '=' token

main.cpp:106: error: expected unqualified-id before "if"
main.cpp:106: error: expected `,' or `;' before "if"

main.cpp:115: error: expected unqualified-id before "if"
main.cpp:115: error: expected `,' or `;' before "if"

main.cpp:130: error: expected unqualified-id before "if"
main.cpp:130: error: expected `,' or `;' before "if"

make.exe: *** [main.o] Error 1

Execution terminated





------------------------------------------------------------------------------------
Here is the source I am working with.



#include <windows.h><br />
#include <winsock.h><br />
#include <iostream><br />
<br />
/*  Declare Windows procedure  */<br />
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);<br />
<br />
/*  Make the class name into a global variable  */<br />
char szClassName[ ] = "WindowsApp";<br />
<br />
int WINAPI WinMain (HINSTANCE hThisInstance,<br />
                    HINSTANCE hPrevInstance,<br />
                    LPSTR lpszArgument,<br />
                    int nFunsterStil)<br />
<br />
{<br />
    HWND hwnd;               /* This is the handle for our window */<br />
    MSG messages;            /* Here messages to the application are saved */<br />
    WNDCLASSEX wincl;        /* Data structure for the windowclass */<br />
<br />
    /* The Window structure */<br />
    wincl.hInstance = hThisInstance;<br />
    wincl.lpszClassName = szClassName;<br />
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */<br />
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */<br />
    wincl.cbSize = sizeof (WNDCLASSEX);<br />
<br />
    /* Use default icon and mouse-pointer */<br />
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);<br />
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);<br />
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);<br />
    wincl.lpszMenuName = NULL;                 /* No menu */<br />
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */<br />
    wincl.cbWndExtra = 0;                      /* structure or the window instance */<br />
    /* Use Windows's default color as the background of the window */<br />
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;<br />
<br />
    /* Register the window class, and if it fails quit the program */<br />
    if (!RegisterClassEx (&wincl))<br />
        return 0;<br />
<br />
    /* The class is registered, let's create the program*/<br />
    hwnd = CreateWindowEx (<br />
           0,                   /* Extended possibilites for variation */<br />
           szClassName,         /* Classname */<br />
           "Windows App",       /* Title Text */<br />
           WS_OVERLAPPEDWINDOW, /* default window */<br />
           CW_USEDEFAULT,       /* Windows decides the position */<br />
           CW_USEDEFAULT,       /* where the window ends up on the screen */<br />
           544,                 /* The programs width */<br />
           375,                 /* and height in pixels */<br />
           HWND_DESKTOP,        /* The window is a child-window to desktop */<br />
           NULL,                /* No menu */<br />
           hThisInstance,       /* Program Instance handler */<br />
           NULL                 /* No Window Creation data */<br />
           );<br />
<br />
    /* Make the window visible on the screen */<br />
    ShowWindow (hwnd, nFunsterStil);<br />
<br />
    /* Run the message loop. It will run until GetMessage() returns 0 */<br />
    while (GetMessage (&messages, NULL, 0, 0))<br />
    {<br />
        /* Translate virtual-key messages into character messages */<br />
        TranslateMessage(&messages);<br />
        /* Send message to WindowProcedure */<br />
        DispatchMessage(&messages);<br />
    }<br />
<br />
    /* The program return-value is 0 - The value that PostQuitMessage() gave */<br />
    return messages.wParam;<br />
}<br />
<br />
<br />
/*  This function is called by the Windows function DispatchMessage()  */<br />
<br />
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
    switch (message)                  /* handle the messages */<br />
    {<br />
        case WM_DESTROY:<br />
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */<br />
            break;<br />
        default:                      /* for messages that we don't deal with */<br />
            return DefWindowProc (hwnd, message, wParam, lParam);<br />
    }<br />
<br />
    return 0;<br />
}<br />
// START PROGRAM HERE<br />
<br />
<br />
  int (PASCAL FAR * lpfn_recv)(SOCKET, char FAR *, int, int);<br />
  int (PASCAL FAR * lpfn_send)(SOCKET, char FAR *, int, int);<br />
  int (PASCAL FAR * lpfn_WSAStartup)(WORD, LPWSADATA);<br />
  int (PASCAL FAR * lpfn_WSACleanup)(void); <br />
  int (PASCAL FAR * lpfn_WSAGetLastError)(void); <br />
<br />
  OFSTRUCT stFile; <br />
  HFILE hFile; <br />
  HINSTANCE hWinSockDLL = 0; <br />
<br />
#ifdef WIN32 <br />
  /* Load 32-bit WinSock DLL */<br />
  hFile = OpenFile("wsock32.dll", (OFSTRUCT FAR*)&stFile,OF_EXIST); <br />
  if (hFile != HFILE_ERROR) <br />
    hWinSockDLL = LoadLibrary ("wsock32.dll");<br />
#else<br />
  /* Load 16-bit WinSock DLL */<br />
  hFile = OpenFile("winsock.dll", (OFSTRUCT FAR*)&stFile,OF_EXIST); <br />
  if (hFile != HFILE_ERROR) <br />
    hWinSockDLL = LoadLibrary ("winsock.dll");<br />
#endif <br />
<br />
  if (hWinsockDLL >= 32) { <br />
    (FARPROC)lpfn_recv = GetProcAddress (hWinsockDLL,"recv");<br />
    (FARPROC)lpfn_send = GetProcAddress (hWinsockDLL,"send");<br />
    (FARPROC)lpfn_WSAStartup = GetProcAddress(hWinSockDLL,"WSAStartup");<br />
    (FARPROC)lpfn_WSACleanup = GetProcAddress(hWinSockDLL,"WSACleanup"); <br />
    (FARPROC)lpfn_WSAGetLastError = GetProcAddress(hWinsockDLL,"WSAGetLastError");<br />
<br />
    /* Check for any null pointers in case GetProcAddress failed */ <br />
    if (!lpfn_recv | !lpfn_send | !lpfn_WSAStartup | <br />
        !lpfn_WSACleanup | !lpfn_WSAGetLastError) { <br />
      FreeLibrary (hWinSockDLL); <br />
      hWinSockDLL = 0; <br />
    } <br />
  } <br />
<br />
  if (!hWinSockDLL) { <br />
    MessageBox (hwnd, "Unable to load winsock.dll","Error"); <br />
  } <br />
<br />

QuestionX64 compilation problems Pin
Varghese Paul M5-Apr-09 20:40
Varghese Paul M5-Apr-09 20:40 
AnswerRe: X64 compilation problems Pin
Stuart Dootson5-Apr-09 22:14
professionalStuart Dootson5-Apr-09 22:14 
QuestionVideo Capture Pin
tns_ranjith5-Apr-09 20:23
tns_ranjith5-Apr-09 20:23 
QuestionHow to make MessageBox () to behave as AfxMessageBox (); Pin
kapardhi5-Apr-09 19:08
kapardhi5-Apr-09 19:08 
AnswerRe: How to make MessageBox () to behave as AfxMessageBox (); Pin
kapardhi5-Apr-09 19:15
kapardhi5-Apr-09 19:15 
GeneralRe: How to make MessageBox () to behave as AfxMessageBox (); Pin
Hamid_RT5-Apr-09 19:40
Hamid_RT5-Apr-09 19:40 
QuestionRe: How to make MessageBox () to behave as AfxMessageBox (); Pin
Iain Clarke, Warrior Programmer5-Apr-09 22:23
Iain Clarke, Warrior Programmer5-Apr-09 22:23 
AnswerRe: How to make MessageBox () to behave as AfxMessageBox (); Pin
peaqea5-Apr-09 19:21
peaqea5-Apr-09 19:21 
GeneralRe: How to make MessageBox () to behave as AfxMessageBox (); Pin
gamefreak229119-Apr-09 16:20
gamefreak229119-Apr-09 16:20 
QuestionCRichEditCtrl on CMDIChildWnd not working Pin
prithaa5-Apr-09 18:11
prithaa5-Apr-09 18:11 
AnswerRe: CRichEditCtrl on CMDIChildWnd not working Pin
prithaa5-Apr-09 20:20
prithaa5-Apr-09 20:20 
QuestionClassWizard not displayed Pin
prithaa5-Apr-09 17:31
prithaa5-Apr-09 17:31 
AnswerRe: ClassWizard not displayed Pin
peaqea5-Apr-09 19:36
peaqea5-Apr-09 19:36 
QuestionRe: ClassWizard not displayed Pin
David Crow6-Apr-09 6:38
David Crow6-Apr-09 6:38 
AnswerRe: ClassWizard not displayed Pin
prithaa7-Apr-09 2:32
prithaa7-Apr-09 2:32 
QuestionPC based application using Microsoft Bluetooth Stack Pin
Kevin Geary5-Apr-09 16:47
Kevin Geary5-Apr-09 16:47 
AnswerRe: PC based application using Microsoft Bluetooth Stack Pin
Soundman32.26-Apr-09 0:32
Soundman32.26-Apr-09 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.