🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2551

Re: Getting Message with WinMain

#2551
From: poojo hackma
Date: Mon, 12 Feb 2007 22:29
91 lines
3871 bytes
Thanks Gambit,

I've been chugging through the Help with the info you gave me, but now I am 
stuck.

Here is why:

CreateWindow requires lpClassName, which can be an ATOM.

RegisterClass() creates an ATOM, but requires a WNDCLASS parameter.

The WNDCLASS structure requires lpClassName.

Now I am stuck in a loop.

I am trying to pop up a notification icon in the taskbar.

What did I missunderstand?


Code: (not all of the variables have been shown)
//---------------------------------------------------------------------------
void Say(const wchar_t* message, wchar_t* title) {
#ifdef _DEBUG
  wchar_t *clob = title;
  wcscat(clob, L"\n");
  wcscat(clob, message);
  MessageBox(NULL, message, L"Debug", MB_OK);
#endif
}
//---------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR 
lpCmdLine, int nCmdShow) {
  if (SHGetAutoRunPath(Path) == FALSE) {
    Say(L"No AutoRun path. Exiting.", L"WinMain");
    return 0; // no CF card detected. Exit
  } else if (IsProcessRunning(L"wceload.exe") == TRUE) { // exit!
    Say(L"Process Is Running. Exiting.", L"WinMain");
    return 0;
  } else {
    wcscpy(buff, Path);
    wchar_t *c;
    c = buff;
    buffTail = c;
    while (*c != 0) {
      if (*c == '\\')
        buffTail = c + 1;
      c++;
    }
  }
  wchar_t *cmdLine;
  wchar_t *exeFile  = L"App1.exe";       // Main executable file
  wchar_t *cabFile  = L"App1.ARM.CAB";   // CAB file for Main setup
  wchar_t *strKey   = L"SOFTWARE\\Apps\\LU App1";
  wchar_t *str404   = L"File Not Found";
  SHNOTIFICATIONDATA nd = {0};
  HICON hIcon = NULL;
#ifdef _DEBUG
  if (1) {
#else
  if (lstrcmpi(lpCmdLine, _T("install")) == 0) { // Card has been inserted
#endif
    DWORD dwStyle = WS_HSCROLL | WS_VSCROLL;
    wchar_t *szClass = L"TSpongeBob";
    wchar_t *szWindow = L"SquarePants";
    ATOM atom = GlobalAddAtom(szClass); // the OS did not like SpongeBob!
    hNdWnd = CreateWindowEx(0, szClass, szWindow, dwStyle,
        0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
        0, 0, AfxGetInstanceHandle(), (LPVOID)&lParam);
    cmdLine = BuildCmdLine(exeFile);
    nd.dwID = dwID;
    nd.clsid = guid;
    nd.npPriority = SHNP_INFORM;
    nd.csDuration = 20;
    nd.hwndSink = hNdWnd;
    nd.hicon = ExtractIconEx(cmdLine, 0, NULL, &hIcon, 1);
    nd.cbStruct = sizeof(SHNOTIFICATIONDATA);
    nd.pszTitle = szTitle;
    if (FileExists(cmdLine) == TRUE) {
      wsprintf(htmlBuf, szFormat, szHtmLink, szTitle,
        szHtmMsg, szInputYes, szInputNo);
      nd.pszHTML = htmlBuf;
      nd.lParam = lParam;
      return SHNotificationAdd(&nd);
      // next, I need a way to capture IDYES or IDNO
    }
  }
  return 0;
}
//--------------------------------------------------------------------------- 
EOF
Technical Details
Message-ID: <45d0ea45$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45d0cc1f@newsgroups.borland.com> <45d0cf87$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ece89f4506d844ba
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "poojo hackma" <poojo.com/mail>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45d0cc1f@newsgroups.borland.com> <45d0cf87$1@newsgroups.borland.com>
Subject: Re: Getting Message with WinMain
Date: Mon, 12 Feb 2007 16:29:39 -0600
Lines: 93
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-Antivirus: avast! (VPS 000712-7, 02/12/2007), Outbound message
X-Antivirus-Status: Clean
NNTP-Posting-Host: 12.191.89.68
Message-ID: <45d0ea45$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1171319365 12.191.89.68 (12 Feb 2007 14:29:25 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail