Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

Empfohlene Antworten

Veröffentlicht

Hallo mal wieder!

Ich sitze nun schon 'ne ganze Weile an dem verflixten Ding:

Ich lasse den Nutzer über CColorDialog eine Farbe auswählen, diese möchte ich in die Form #ffffff bringen, um sie in einem HTML-Dokument zu verwenden. Dazu habe ich die Funktion RGBToHtml(COLORREF color, LPTSTR out, long Buffer) gefunden.

Meine Funktion sieht so aus:


#include "atlutil.h"

...

CColorDialog color(RGB(255, 128, 0), CC_FULLOPEN);

COLORREF col;

LPTSTR htmlCol;


if(color.DoModal()==IDOK)

 {

  col=color.GetColor();


  RGBToHtml(col, htmlCol, 7);

 }//end if(color.DoModal()==IDOK)

Das Problem ist, dass ich keinen Farbwert in htmlCol bekomme. Ich habe es mit LPTSTR *htmlCol und LPTSTR htmlCol[8] versucht, es passierte nichts.

  • Autor

Es klappt, wie immer.


#include "atlutil.h"

...

CColorDialog color(RGB(255, 128, 0), CC_FULLOPEN);

COLORREF col;

TCHAR htmlCol[8];


if(color.DoModal()==IDOK)

 {

  col=color.GetColor();


  RGBToHtml(col, htmlCol, 8);

 }//end if(color.DoModal()==IDOK)

Da habe ich aber mal noch eine Frage:

Warum kommt es oft vor, dass die Dateitypen, die als Argument für eine Funktion vorgegeben sind, nicht funktionieren; wie hier TCHAR statt LPTSTR? :confused:

Warum kommt es oft vor, dass die Dateitypen, die als Argument für eine Funktion vorgegeben sind, nicht funktionieren; wie hier TCHAR statt LPTSTR? :confused:
Die funktionieren schon. Man muss sie nur richtig benutzen. In der Doku zu RGBToHtml steht:

pbOut

Caller-allocated buffer to receive the text for the HTML color value.

Da steht, dass das ein Puffer sein muss, den der Aufrufer reserviert. Übergeben wird der in Form eines Zeigers (anders geht es in C nicht). Das Problem ist eigentlich meistens, dass man dem Parametertypen LPTSTR nicht direkt ansieht, dass es nur ein Zeiger ist.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.