Sim bei Enter drücken (Geräusch)
-
Dann bin ich auch überfragt...müsste mich jetzt auch zuerst mal gaaaanz tief einlesen, warum der Beep überhaupt kommt...
-
Der Beep wird eventuell von IsDialogMessage erzeugt.
-
Wenn sich Edit-Control also auf einem Dialog befindet, müsstest du glaube ich noch die Nachricht WM_GETDLGCODE behandeln.
-
nene, ist auf nem normalen window :
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_HREDRAW | CS_VREDRAW;; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, (LPCTSTR)IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, (LPCTSTR)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 */ "Sintima Multi-Chnnel Support System", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 610, /* The programs width */ 400, /* 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 */ );
-
ich werds jetzt testen und dann die lösung hier posten.
-
WM_CHAR musst du abfangen dann ist der beep weg hier
LRESULT CALLBACK EditProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch(msg) { case WM_CHAR: case WM_KEYDOWN: if( wParam == VK_RETURN ) return 0; break; } return CallWindowProc( oldEditProc, hWnd, msg, wParam, lParam ); }
-
das problem ist jetzt, das ich in das Edit net schreiben kann
-
jop dann machste was falsch
-
LRESULT CALLBACK MsgControl (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { char text[255]; //text von hMsg char txt[255]; switch(msg) { case WM_CHAR: case WM_KEYDOWN: if (wParam == VK_RETURN) { SendMessage(hMsg, WM_GETTEXT, sizeof(text), (ULONG)text); SendMessage(hChat, WM_GETTEXT, sizeof(txt), (ULONG)txt); send_msg(text, txt); return 0; } break; default : return CallWindowProc ((WNDPROC) PrevhMsg, hwnd, msg, wParam, lParam); } return 0; }is das calback
und hier der ganze code :
#include <windows.h> #include "SinSupport_private.h" #include<Richedit.h> /* ::::::: controlls IDs :::::::: */ const int TXT_CHAT = 870; const int TXT_MSG = 535; const int BTN_SEND = 90; const int BTN_CONNECT = 100; const int CMB_CHANNEL = 54; const int BTN_DICONNECT = -100; /* ::::::::::::: CONTROLLS HWNDs :::::::::::: */ static HWND hChat; static HWND hMsg; static HWND hSend; static HWND hChannel; /* SUBCLASSING VARS */ static LONG_PTR PrevhMsg; static LONG_PTR PrevhChat; static LONG_PTR PrevhChannel; /* CAllBACK FÜR WINDOW */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* CALLBACK FÜR hCHAT */ LRESULT CALLBACK ChatControl (HWND, UINT, WPARAM, LPARAM); /* CALLBACK FÜR hMsg */ LRESULT CALLBACK MsgControl (HWND, UINT, WPARAM, LPARAM); /* CHANNEL */ LRESULT CALLBACK ChannelControl (HWND, UINT, WPARAM, LPARAM); /* SEND FUCNTION */ int send_msg(char *, char *); /* ADD TEXTFUCNTION */ /* Make the class name into a global variable */ char szClassName[ ] = "support"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HINSTANCE insChat = insChat = LoadLibrary("RichEd32.dll"); /* LOAD RICHTEXT CONTROLL DLL */ 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_HREDRAW | CS_VREDRAW;; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, (LPCTSTR)IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, (LPCTSTR)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 */ "Sintima Multi-Chnnel Support System", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 610, /* The programs width */ 400, /* 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 */ FreeLibrary(insChat); return messages.wParam; }/* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { char txt[256]; // Vtext of hMsg char text[256]; int index_design_0; int index_code_0; int index_info_0; int index_info_1; int index_support_0; switch (message) /* handle the messages */ { case WM_CREATE: /* ::::: DIE COMBOBOX UND BUTTON ::: */ hChannel = CreateWindowEx(WS_EX_CLIENTEDGE, "ComboBox", "", WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|CBS_HASSTRINGS, 100, 10, 200, 500, hwnd, (HMENU)CMB_CHANNEL, ((LPCREATESTRUCT) lParam) -> hInstance, 0); PrevhChannel = SetWindowLongPtr (hChannel, GWLP_WNDPROC, (LONG_PTR) ChannelControl); CreateWindowEx(WS_EX_CLIENTEDGE,"Button", "Verbinden", WS_CHILD | WS_VISIBLE, 310, // x-pos 10, //y-pos 100, // width 25, //height hwnd, (HMENU)BTN_CONNECT, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); CreateWindowEx(WS_EX_CLIENTEDGE,"Button", "Trennen", WS_CHILD | WS_VISIBLE, 415, // x-pos 10, //y-pos 100, // width 25, //height hwnd, (HMENU)BTN_DICONNECT, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); /* ::: Chat Control (RichText) */ hChat = CreateWindowEx(WS_EX_CLIENTEDGE, "RichEdit", "", WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_READONLY|ES_AUTOVSCROLL, // style 10, // x -Position 40, // y-Postiotns 580, // länge 290, // höhe hwnd, (HMENU)TXT_CHAT, ((LPCREATESTRUCT) lParam) -> hInstance, 0); SendMessage(hChat, EM_SETEVENTMASK, 0, ENM_LINK); PrevhChat = SetWindowLongPtr (hChat, GWLP_WNDPROC, (LONG_PTR) ChatControl); /* ::: MSG Control (EditBox) */ hMsg = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "", WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, // style 10, // x -Position 335, // y-Postiotns 510, // länge 25, // höhe hwnd, (HMENU)TXT_MSG, ((LPCREATESTRUCT) lParam) -> hInstance, 0); /* CALLBACK */ PrevhMsg = SetWindowLongPtr (hMsg, GWLP_WNDPROC, (LONG_PTR) MsgControl); /* ::: Button Send Controll ::: */ hSend = CreateWindowEx(WS_EX_CLIENTEDGE,"Button", "Send", WS_CHILD | WS_VISIBLE, 525, // x-pos 335, //y-pos 65, // width 25, //height hwnd, (HMENU)BTN_SEND, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); /* SEND MESSAGES */ index_design_0 = SendMessage(hChannel, CB_ADDSTRING, 0, (LPARAM)"Design Channel"); index_code_0 = SendMessage(hChannel, CB_ADDSTRING, 0, (LPARAM)"Programmierer Channel"); index_info_0 = SendMessage(hChannel, CB_ADDSTRING, 0, (LPARAM)"Info Channel (allgemein)#1"); index_info_1 = SendMessage(hChannel, CB_ADDSTRING, 0, (LPARAM)"Info Channel (allgemein) #2"); index_support_0 = SendMessage(hChannel, CB_ADDSTRING, 0, (LPARAM)"Techn. SupportChannel "); SetFocus(hMsg); break; /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ case WM_COMMAND: if (wParam == BTN_SEND) { SendMessage(hMsg, WM_GETTEXT, sizeof(text), (ULONG)text); SendMessage(hChat, WM_GETTEXT, sizeof(txt), (ULONG)txt); send_msg(text, txt); } break; /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ case WM_PAINT: PAINTSTRUCT ps; HDC hDC; hDC = BeginPaint(hwnd, &ps); { SetBkMode(hDC,TRANSPARENT);// background color TextOut(hDC, 10, 12, "Channel :", sizeof("Channel:")); // Text asugben } EndPaint(hwnd, &ps); break; /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ 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; } /* :::::::::::::::::::: CALLBACK FÜR hChat :::::::::: */ LRESULT CALLBACK ChatControl (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HMENU hMenu; // PopUp menu POINT point; // Position int select; switch(msg) { /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ case WM_CONTEXTMENU: hMenu = CreatePopupMenu (); InsertMenu (hMenu, 0, MF_BYPOSITION, 0, "Kopieren"); POINTSTOPOINT (point, lParam); if ((point.x == -1) && (point.y == -1)) { point.x = point.y = GetSystemMetrics (SM_CXEDGE); ClientToScreen (hwnd, &point); // Die Koordinaten auf unser Fenster legen } select = (int) TrackPopupMenu (hMenu, TPM_CENTERALIGN|TPM_LEFTBUTTON|TPM_RETURNCMD, point.x, point.y, 0, hwnd, 0); if (select == 0) { // Copy to clipboard } break; /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ case WM_NOTIFY: if (wParam == EN_LINK) { MessageBox(NULL, "dfsdf", "dfsdf", MB_OK); ShellExecute(hChat, "open", "http://www.Meine-Hompage.de/cpp", NULL,NULL,SW_SHOWDEFAULT); } break; /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ case WM_DESTROY: DestroyMenu (hMenu); PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default : return CallWindowProc ((WNDPROC) PrevhChat, hwnd, msg, wParam, lParam); } return 0; } /* :::::::::::::::::::: CALLBACK FÜR hMsg :::::::::: */ LRESULT CALLBACK MsgControl (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { char text[255]; //text von hMsg char txt[255]; switch(msg) { case WM_CHAR: case WM_KEYDOWN: if (wParam == VK_RETURN) { SendMessage(hMsg, WM_GETTEXT, sizeof(text), (ULONG)text); SendMessage(hChat, WM_GETTEXT, sizeof(txt), (ULONG)txt); send_msg(text, txt); return 0; } break; default : return CallWindowProc ((WNDPROC) PrevhMsg, hwnd, msg, wParam, lParam); } return 0; } /* ::::::::::::::::::: CALLBACK FÜR hCHANNEL ::::::::: */ LRESULT CALLBACK ChannelControl (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { default: return CallWindowProc ((WNDPROC) PrevhChannel, hwnd, msg, wParam, lParam); } return 0; } /* ::::::::::::::::::::::::::::::::::::::::::::::: FUNCTIONEN :::::::::::::::::::::::::::::::::: */ /*::: SEND FUCNTION ::::*/ int send_msg(char * text, char * txt) { /* Formatierung vorbereiten */ CHARFORMAT format; format.cbSize = sizeof(CHARFORMAT); format.dwMask = CFM_COLOR; format.crTextColor = RGB(99, 99, 99); format.dwEffects = CFE_BOLD; /* Den Text ausgäben */ SendMessage(hMsg, WM_SETTEXT, 0, (ULONG)""); // Textfiel von hMsg leeren SendMessage(hChat, WM_SETTEXT, 0, (ULONG)strcat(strcat(txt, text), "\r\n")); // text hinzufügen SendMessage(hChat, EM_SETSEL, (WPARAM)sizeof(txt)-1, (LPARAM)(strlen(txt)-1)+(strlen(text)-1)); // text auswählen SendMessage(hChat, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); // Farbe setzen SendMessage(hChat, EM_SCROLL, SB_PAGEDOWN, 0); // Scrollen nach unten SetFocus(hMsg); // Focus setzen SendMessage(hChat, EM_AUTOURLDETECT, 1, 0); return 0; }
-
Dein Switchstatement ist falsch.
Du fängst ALLE WM_CHAR Nachrichten ab. Der code unter "default" wird ja nie ausgeführt sondern nachdem break und verlassen des Switchs gibst du dnan am ende der funktion 0 zurück. machs einfach so dann funzts auch
LRESULT CALLBACK MsgControl (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { char text[255]; //text von hMsg char txt[255]; switch(msg) { case WM_CHAR: case WM_KEYDOWN: if (wParam == VK_RETURN) { SendMessage(hMsg, WM_GETTEXT, sizeof(text), (ULONG)text); SendMessage(hChat, WM_GETTEXT, sizeof(txt), (ULONG)txt); send_msg(text, txt); return 0; } break; } return CallWindowProc ((WNDPROC) PrevhMsg, hwnd, msg, wParam, lParam); }