Zum Inhalt springen

Smoggy

Mitglieder
  • Gesamte Inhalte

    35
  • Benutzer seit

  • Letzter Besuch

Beiträge von Smoggy

  1. Also um an Mainframe-Objekt zu kommen, gibt es die Holzhammer-Methode:

    CMyApp* pApp = (CMyApp*) AfxGetApp();

    pApp->m_pMainFrame->

    Eine Form-Switch in einer SDi hab ich auch mal gemacht:

    -Als Ressourcen hast du IDD_FORM_1,IDD_FORM_2,IDD_FORM_3

    ´+ die dazugehörigen Klassen

    void CMainFrame::SwitchToForm(int nForm)

    {

    ::SetCursor(::LoadCursor(NULL, IDC_WAIT));

    CView* pOldActiveView = GetActiveView(); // Altes View merken

    CView* pNewActiveView;

    CDocument* pDoc = GetActiveDocument();

    switch(nForm)

    {

    case IDD_FORM_1:

    pNewActiveView = (CView*)new CView1;

    break;

    case IDD_FORM_2:

    pNewActiveView = (CView*)new CView2;

    break;

    case IDD_FORM_3:

    pNewActiveView = (CView*)new CView3;

    break;

    }

    pNewActiveView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,

    rectDefault, this, AFX_IDW_PANE_FIRST, NULL);

    // Neu erstelltes View anzeigen und altes View verbergen

    pNewActiveView->ShowWindow(SW_SHOW); // Neues Fenster anzeigen

    pOldActiveView->ShowWindow(SW_HIDE); // Altes Fenster verbergen

    // Neu erstelltes View mit dem Document verbinden und

    // altes View vom Document trennen

    pDoc->AddView(pNewActiveView);

    pDoc->RemoveView(pOldActiveView);

    SetActiveView(pNewActiveView); // Aktives View ändern

    pNewActiveView->OnInitialUpdate();

    RecalcLayout(); // Fenster anpassen

    delete pOldActiveView; // Altes View löschen

    ::SetCursor(::LoadCursor(NULL,IDC_ARROW));

    }

    Falls fargen sind, einfach melden

  2. Möchtest du etwas vom Borland Builder zum VC portieren???????

    Label gibts in VC nicht.

    Aus der VC-Hilfe:

    Convert an integer to a string:

    char *_itoa( int value, char *string, int radix );

    Parameters:

    value = Number to be converted

    string = String result

    radix = Base of value; must be in the range 2 – 36

    Das allererste, was wir in AWE in der Schule gelernt haben: Die Hilfe benutzen.

  3. Ja und nein. komplett selber zeichnen ist IMHO noch zu aufwendig

    Hier der Artikel*******************************************************

    ******************************************************************

    List Box, Draw Thyself

    Dear Dr. GUI,

    Please forgive me if I am suffering from amnesia and have already bugged you about this.... I remember I was going to send you e-mail, I just don't remember if I actually sent it. So on with my question...

    I need to have individual lines inside a CListBox to possibly be different colors. I know that I can change the color for all of the text but that really doesn't help me that much. I have searched and searched for something that would help me do this and all I can find is how easy it is to do in Visual Basic. Is there any solution in VC++ that will give me this functionality?

    Thanks!

    Dr. GUI replies:

    The good doctor notes that this won't be trivial, but your problem gives him a great chance to show how to use "owner-draw" list boxes. "Owner-draw" is a common Windows technique whereby Windows asks you to draw the item that needs to be drawn. Many Windows controls, including buttons and menus, also support owner-drawing.

    So, for this example, we'll use an owner-drawn list box. The entire process involves just four simple steps:

    Derive a class from CListBox.

    Override the CListBox::MeasureItem virtual function to specify the height for each item.

    Override the CListBox::DrawItem virtual function to perform the painting.

    Override the CListBox::CompareItem virtual function to determine the order in which the a string has to be added. This is necessary only if you wish to have a sorted list.

    Note that the list box should have the LBS_OWNERDRAWVARIABLE and LBS_HASSTRINGS styles set. You need to select these styles for the list box when you create it using a resource editor. Otherwise, if you create the list box dynamically, specify these styles during creation.

    The following CLineListBox class provides an implementation. Here the color for the text is stored as item data and retrieved during painting. First, we implement the AddItem function, which adds the string to the list box and stores the color in the 32-bit item data associated with the string:

    void CLineListBox::AddItem(const CString& str, COLORREF rgbText)

    {

    int nIndex;

    nIndex = AddString(str);

    if( CB_ERR != nIndex )

    SetItemData(nIndex, rgbText);

    }

    Next, we override DrawItem to draw the string in the color stored in the item data:

    void CLineListBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)

    {

    CDC dc;

    CRect rcItem(lpDIS->rcItem);

    UINT nIndex = lpDIS->itemID;

    COLORREF rgbBkgnd = ::GetSysColor(

    (lpDIS->itemState & ODS_SELECTED) ?

    COLOR_HIGHLIGHT : COLOR_WINDOW);

    dc.Attach(lpDIS->hDC);

    CBrush br(rgbBkgnd);

    dc.FillRect(rcItem, &br);

    if( lpDIS->itemState & ODS_FOCUS )

    dc.DrawFocusRect(rcItem);

    if( nIndex != (UINT)-1 )

    {

    // The text color is stored as the item data.

    COLORREF rgbText = (lpDIS->itemState & ODS_SELECTED) ?

    ::GetSysColor(COLOR_HIGHLIGHTTEXT) : GetItemData(nIndex);

    CString str;

    GetText(nIndex, str);

    dc.SetBkColor(rgbBkgnd);

    dc.SetTextColor(rgbText);

    dc.TextOut(rcItem.left + 2, rcItem.top + 2, str);

    }

    dc.Detach();

    }

    Then, we have to override MeasureItem to tell Windows how high each item is. (Note that the items could each be of different height if we wanted.)

    void CLineListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)

    {

    // Set the item height. Get the DC, select the font for the

    // list box, and compute the average height.

    CClientDC dc(this);

    TEXTMETRIC tm;

    CFont* pFont = GetFont();

    CFont* pOldFont = dc.SelectObject(pFont);

    dc.GetTextMetrics(&tm);

    dc.SelectObject(pOldFont);

    lpMIS->itemHeight = tm.tmHeight + 4;

    }

    Finally, we support sorting by overriding CompareItem:

    int CLineListBox::CompareItem(LPCOMPAREITEMSTRUCT lpCIS)

    {

    CString str1, str2;

    GetText(lpCIS->itemID1, str1);

    GetText(lpCIS->itemID2, str2);

    return str1.Compare(str2);

    }

    All that is needed to see the new list box in action is to create a variable of class CLineListBox, associate it with a list box window (perhaps using Class Wizard), and set the color for each text entered using SetItemData. If no color is specified for a string, it gets displayed in black when it is not selected. Suppose m_listBox is a variable of type, ClineListBox. In that case you may use:

    m_listBox.AddItem("Hello", RGB(255, 0, 0)); // Add string, "Hello", and display it in red.

    m_listBox.AddItem("Windows", RGB(255, 0, 255)); // Add string, "Windows", and display it in magenta.

    m_listBox.AddItem("Color listbox"); // Add string, "Color listbox", and display it in default black."

  4. Mach am besten folgendes FixedRows und FixedCols im Obejektinspector auf 1 setzen. Dies werden deine Beschriftungen.

    z.B. 3 nutzbaren Spalten und 5 nutzbaren reihen:

    //Anzahl der reihen setzen:

    StringGrid->RowCount = 5+1; //+1 für den Kopf des Grids

    //Anzahl der Spalten setzen

    StringGrid->ColCount = 5;

    //Beschriftung der Spalten:

    StringGrid->Cells[0][0]= "Laufnummer";

    StringGrid->Cells[1][0]= "zweite Spalte";

    StringGrid->Cells[2][0]= "dritte Spalte";

    StringGrid->Cells[3][0]= "vierte Spalte";

    //Beschriftung der Reihen

    for (int i=1;i<StringGrid->RowCount;i++)

    StringGrid->Cells[0]=IntToStr(i); //trägt in die reihen 1,2,3 usw ein

    //zugriff auf die Zellen

    StringGrid->Cells[aColumn][aRow];

    Was möchtest du noch wissen??

  5. auch wenn ich einer der wenigen bin, die was mit karneval anfangen können.....

    aber eine bitte:

    nicht alle sind sturzbesoffen, nicht alle laufen mit verordneter fröhlichkeit herum, nicht alle gehen fremd.....

    also bitte nicht immer verallgemeinern. die meisten wollen wirklich einfach nur feiern....

  6. Standard ist eigentlich, daß sich der Mauszeiger ändert, und nicht der Button selbst hervorgehoben wird, wenn die Maus sich über dem Button befindet.

    Könnte in etwa so aussehen (c+p, sorry):

    Im Konstruktor:

    m_hButtonCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_EXAMPLE));

    BOOL CExample::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)

    {

    CString sClassName;

    ::GetClassName(pWnd->GetSafeHwnd(),sClassName.GetBuffer(80),80);

    if (sClassName=="Button" && m_hButtonCursor)

    {

    ::SetCursor(m_hButtonCursor);

    return TRUE;

    }

    return CFormView::OnSetCursor(pWnd, nHitTest, message);

    }

    Wäre eine Möglichkeit von vielen (wie immer......)

  7. Der HotSync ist eigentlich narrensicher. Kann mir nur vorstellen, daß es Probs mit deinem USB-Port gibt. Ich würde den mal neu einrichten/installieren. Wenn das auch nicht hilft, nimm mal die Dockingstation von der Arbeit mit nachhause und prüfe ob es denn seriell klappt. Wenn ja, ist die USB-Dockingstation hin, wenn nein, dann hast du ein Problem....:-)

  8. In der oben genannte Klasse wird das gliche behandelt, nur eben mit einem Static.

    Wenn man über das Static(den Button) fährt, ändert sich der Cursor, klickt man ihn an, öffnet sich ne HP.

    Da ein static genau wie ein Button auch nur ein Fenster ist, solltest du die funktionsweise eigentlich leicht auf dein Prog übertragen können.

    Such einfach mal nach "Paul Dilascia CStaticLink" und wuschel dich dann durch. ist eigentlich sehr einfach. Und ne neue Klasse ist auch nicht von nöten.

    (Hatte das Damals in einem FormView und einem Dialog verwirklicht)

    Greez

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...