עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה MSGBOX ב-C++

Featured Replies

פורסם

אני מנסה לתכנת ב-C++ בסביבת VS2005.

אני מנסה ליצור MSGBOX פשוט ואני נעזר באתר הזה למרות שהוא כותב שם ל-C, ההסברים שלו טובים.

כשאני מנסה לקמפל את הקוד הבא:

#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
return 0;
}

אני מקבל הודעת שגיאה:

error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [22]' to 'LPCWSTR'

חפרתי באינטרנט לגבי ה-LPCWSTR והגעתי לזה שמדובר TYPEDEF של wchar_t.

אין לי מושג אם לעשות המרה, וכל העניין הזה של Win32 app חדש לי.

למישהו יש רעיונות?

פורסם

תנסה:

MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);

או שתגדיר 3 משתנים חדשים של טיפוסי LPCWSTR, כהודעות שאתה רוצה לשים, ותעביר אותם כפרמטרים.

פורסם
  • מחבר

תנסה:

MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);

זהו שזה לא עובד.

או שתגדיר 3 משתנים חדשים של טיפוסי LPCWSTR, כהודעות שאתה רוצה לשים, ותעביר אותם כפרמטרים.

השאלה היא, איך?

ניסיתי:

LPCWSTR str="test string"

אבל גם פה אני מקבל את אותה ההודעה.

פורסם

תשתמש ב-MessageBoxA, זו גרסת ה-Ascii של MessageBox, יש גם MessageBoxW שהיא גרסת ה-Wide ?(Unicode)

ככה זה עם הרבה פונקציות ב-API של Windows. כנראה שהגדרת את הפרויקט שלך ל-Unicode.

אפשר גם להמיר את המחרוזות ל-Unicode -

MessageBoxW(NULL, L"Goodbye, cruel world!", L"Note", MB_OK);

פורסם
  • מחבר

מעולה :xyxthumbs:

שתי השיטות עובדות.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.