Hi, can you help me? I have this program and when I compile it, it write me this:
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl OnMessage(unsigned int,long)" (?OnMessage@@YAXIJ@Z) referenced in function "int __stdcall DialogProc(struct HWND__ *,unsigned int,unsigned int,long)" (?DialogProc@@YGHPAUHWND__@@IIJ@Z)
1> fatal error LNK1120: 1 unresolved externals

.
.
.
void OnMessage(WPARAM wParam,LPARAM lParam);

INT_PTR CALLBACK DialogProc(HWND hlok, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   TCHAR chText[200];
   switch ( uMsg )
   {
   case WTM_CITAJ_DATA:
   OnMessage(wParam, lParam);
   {
   DWORD *LRM=(DWORD*)lParam;
   }
   break;
      case WM_COMMAND:
         switch ( LOWORD(wParam) )
         {
            case IDCANCEL:
               EndDialog(hlok, IDCANCEL);
               break;
            
            case IDC_BUTTON1:
               (OpenPort(m_commPort+1));
               if (IsDlgButtonChecked(hlok, IDC_BUTTON1))
               {
                        EnableWindow(GetDlgItem(hlok, IDC_BUTTON1), TRUE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON2), FALSE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON1), FALSE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON2), TRUE);
               }
               break;
            
            case IDC_BUTTON2:
               ClosePort();
               if (IsDlgButtonChecked(hlok, IDC_BUTTON2))
               {
                        EnableWindow(GetDlgItem(hlok, IDC_BUTTON2), TRUE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON1), FALSE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON2), FALSE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON1), TRUE);
               }
               break;
            
            case IDC_BUTTON3:
               StartReadData( hlok );
               if (IsDlgButtonChecked(hlok, IDC_BUTTON3))
               {
                        EnableWindow(GetDlgItem(hlok, IDC_BUTTON3), TRUE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON4), FALSE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON3), FALSE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON4), TRUE);
               }
               break;
            
            case IDC_BUTTON4:
               StopReadData();
               if (IsDlgButtonChecked(hlok, IDC_BUTTON4))
               {
                        EnableWindow(GetDlgItem(hlok, IDC_BUTTON4), TRUE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON3), FALSE);
               }
               else
               {
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON4), FALSE);
                  EnableWindow(GetDlgItem(hlok, IDC_BUTTON3), TRUE);
               }
               break;

                  case IDC_RADIO1:
                     
                     if(IsDlgButtonChecked(hlok, IDC_RADIO1) == BST_CHECKED)
                     {
                     m_commPort = 0;
                     CheckDlgButton(hlok, IDC_RADIO1, BST_UNCHECKED);
                     }
                     else
                     {   
                     CheckDlgButton(hlok, IDC_RADIO1, BST_CHECKED);
                     }
                     break;

                  case IDC_RADIO2:
                     
                     if(IsDlgButtonChecked(hlok, IDC_RADIO2) == BST_CHECKED)
                     {
                     m_commPort = 1;
                     CheckDlgButton(hlok, IDC_RADIO2, BST_UNCHECKED);
                     }
                     else
                     {   
                     CheckDlgButton(hlok, IDC_RADIO2, BST_CHECKED);
                     }
                     break;

                  case IDC_RADIO3:

                     if(IsDlgButtonChecked(hlok, IDC_RADIO3) == BST_CHECKED)
                     {
                     m_commPort = 2;
                     CheckDlgButton(hlok, IDC_RADIO3, BST_UNCHECKED);
                     }
                     else
                     {   
                     CheckDlgButton(hlok, IDC_RADIO3, BST_CHECKED);
                     }
                     break;

                  case IDC_RADIO4:

                     if(IsDlgButtonChecked(hlok, IDC_RADIO4) == BST_CHECKED)
                     {
                     m_commPort = 3;
                     CheckDlgButton(hlok, IDC_RADIO4, BST_UNCHECKED);
                     }
                     else
                     {   
                     CheckDlgButton(hlok, IDC_RADIO4, BST_CHECKED);
                     }
                     break;
         }
         break;
   }
   return FALSE;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
   LPSTR lpCmdLine, int nShow)
{
   return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1),
      NULL, (DLGPROC)DialogProc);
}

Have you defined OnMessage()? Where is it?

Thank you very much, I havent declared this function. Now it is good.

This article has been dead for over six months. Start a new discussion instead.