cambalinho 142 Practically a Posting Shark

maybe i'm the 1st seen these problem, maybe i'm not...
i noticed before and i didn't make case, but now i'm horry about it...
i'm logined from 1h(maybe more) and everytime that answer me, i never recive a mail notification, because i'm logined.
i can tested more about it, but it's strange :(
how i know that?
1 - normaly, when i'm log off, i recive the mail notification;
2 - when i'm logined and i notice very time to answer me, i do page refresh and i see the answer, but not the mail notification.
these is strange, but i'm noticed now :(

cambalinho 142 Practically a Posting Shark

now the code give me 2 problems:
1 - the '_1' ins't defined, so i use '1';
2 - the value is showed '1', but seems not be setted:(

#include <iostream>
#include <functional>

using namespace std;

template <typename T>
class property
{
private:
    T PropertyValue;
    std::function<T(void)> getf;
    std::function<void(T)> setf;
public:

    property(T value)
    {
        PropertyValue=value;
    };

    property(std::function<T(void)> GetFunction=nullptr,std::function<void(T)> SetFunction=nullptr)
    {
        setf=SetFunction;
        getf=GetFunction;
    }

    property& operator=(T value)
    {
        if(getf==nullptr || setf==nullptr)
            PropertyValue=value;
        else
            setf(value);
        return *this;
    }

    T& operator=(property value)
    {
        if(value.getf==nullptr || value.setf==nullptr)
            return value.PropertyValue;
        else
            return value.getf();
    }

    friend ostream& operator<<(ostream& os, const property& dt)
    {
        if(dt.getf==nullptr && dt.setf==nullptr)
            os << dt.PropertyValue;
        else if (dt.getf!=nullptr)
            os << dt.getf();
        return os;
    }

    friend istream& operator>>(istream &input, property &dt)
    {
        input >> dt.PropertyValue;
        if (dt.setf!=nullptr)
            dt.setf(dt.PropertyValue);
        return input;
    }
};

class test
{
private:
    int age;
    int getage()
    {
        return age;
    }
    void setage(int value)
    {
        age=value;
    }
public:

    test() : Name(), Age(std::bind(&test::getage, this),std::bind(&test::setage, this, 1))
    {

    }
    property<string> Name;//can i inicializate them here?
    property<int> Age;

};

test a;

int main()
{
    a.Name="joaquim "  "Miguel";
    a.Age=10+15;
    cout << a.Age << endl;
    cout << "what is your name?\n";
    cin >> a.Age;
    cout << "your name is: " << a.Age << endl;
    return 0;
}

see the comment, please or we left for later(after the problems) ;)

cambalinho 142 Practically a Posting Shark

sorry, but that variable is used, only, when i don't need the getf and setf

cambalinho 142 Practically a Posting Shark

i belive these isn't correct too:

friend istream& operator>>(istream &input,property &dt)
    {
        if(dt.getf==nullptr && dt.setf==nullptr)
            input << dt.PropertyValue;
        else if (dt.setf!=nullptr)
            input << dt.setf() //maybe these isn't completed\corrected
        return input;
    }

yes... i continue with some errors :(

anotherthing: when i'm logined, can i recive the mail notification? i'm asking these, because i'm not reciving when i'm logined :(

cambalinho 142 Practically a Posting Shark

sorry, but i continue with some errors :(

#include <iostream>
#include <functional>

using namespace std;

template <typename T>
class property
{
private:
    T PropertyValue;
    std::function<T(void)> getf;
    std::function<void(T)> setf;
public:

    property(T value)
    {
        PropertyValue=value;
    };

    property(std::function<void(void)> GetFunction=nullptr,std::function<T(void)> SetFunction=nullptr)
    {
        setf=SetFunction;//error
        getf=GetFunction;
    }

    property& operator=(T value)
    {
        if(getf==nullptr || setf==nullptr)
            PropertyValue=value;
        else
            setf(value);
        return *this;
    }

    T& operator=(property value)
    {
        if(value.getf==nullptr || value.setf==nullptr)
            return value.PropertyValue;
        else
            return value.getf();
    }

    friend ostream& operator<<(ostream& os, const property& dt)
    {
        if(dt.getf==nullptr && dt.setf==nullptr)
            os << dt.PropertyValue;
        else if (dt.getf!=nullptr)
            os << dt.getf();
        return os;
    }

    friend istream& operator>>(istream &input,property &dt)
    {
        if(dt.getf==nullptr && dt.setf==nullptr)
            input << dt.PropertyValue;
        else if (dt.setf!=nullptr)
            input << dt.setf();
        return input;
    }
};

class test
{
private:
    int age;
    int getage()
    {
        return age;
    }
    void setage(int value)
    {
        age=value;
    }
public:

    test():Name(), Age(std::bind(&test::getage, this), std::bind(&test::setage, this))//error
    {
        //nothing
    }
    property<string> Name;
    property<int> Age;

};

test a;

int main()
{
    a.Name="joaquim "  "Miguel";
    a.Age=10+15;
    cout << a.Age << endl;
    cout << "what is your name?\n";
    cin >> a.Age;
    cout << "your name is: " << a.Age << endl;
    return 0;
}

error:
- no matching function for call to 'property<int>::property(std::_Bind_helper<false, int (test::*)(), test* const>::type, std::_Bind_helper<false, void (test::*)(int), test* const>::type)'
- no match for 'operator=' (operand types are 'std::function<void(std::basic_string<char>)>' and 'std::function<std::basic_string<char>()>')

theres more errors :(

cambalinho 142 Practically a Posting Shark

thanks for that information... thanks
now i have more errors:
on test class constructor i have these error:

"call of overloaded 'property()' is ambiguous"
these don't make sence to me.

and

property<int> Age(&getage,&setage);

give 2 same errors:
"expected identifier before '&' token"
i have more errors, but let see if we can fix these problems

cambalinho 142 Practically a Posting Shark

i'm build a completed new code for properties:

#include <iostream>
#include <functional>

using namespace std;

template <typename T>
class property
{
private:
    T PropertyValue;
    //i think these is ok, but something seems not
    std::function<T(void)> getf;
    std::function<void(T)> setf;
public:
    property()
    {
        getf=NULL;
        setf=NULL;
    };

    property(T value)
    {
        PropertyValue=value;
    };

    property(std::function<void(void)> GetFunction=NULL,std::function<T(void)> SetFunction=NULL)// what isn't right here?
    {
        setf=SetFunction;
        getf=GetFunction;
    }

    property& operator=(T value)
    {
        if(getf==NULL || setf==NULL)
            PropertyValue=value;
        else
            setf(value);
        return *this;
    }

    T& operator=(property value)
    {
        if(getf==NULL || setf==NULL) 
            return PropertyValue;
        else
            return getf();
    }

    friend ostream& operator<<(ostream& os, const property& dt)
    {
        if(getf==NULL && setf==NULL) //error these don't make sence to me :(
            os << dt.PropertyValue;
        else if (getf!=NULL)
            os << getf();
        else
            return 0;
        return os;
    }

    friend istream& operator>>(istream &input,property &dt)
    {
        if(getf==NULL && setf==NULL) //error these don't make sence to me :(
            input << dt.PropertyValue;
        else if (setf!=NULL)
            input << setf();
        else
            return 0;
        return input;
    }
};

class test
{
private:
    int age;
    int getage()
    {
        return age;
    }
    void setage(int value)
    {
        age=value;
    }
public:

    test()
    {
        //nothing
    }
    property<string> Name;
    property<int> Age(&getage,&setage); //error

};

test a;

int main()
{
    a.Name="joaquim "  "Miguel";
    a.Age=10+15;
    cout << a.Age << endl;
    cout << "what is your name?\n";
    cin >> a.Age;
    cout << "your name is: " << a.Age << endl;
    return 0;
}

but i get 23 errors, if is need, i can give all the info.
sorry, but i'm not getting help :(
please someone tell me something

cambalinho 142 Practically a Posting Shark

i'm learning, by work, how use win32 forms applications. but i'm geting a problem: the label(STATIC class) is give me flickers :(
i had tryied use the WS_EX_COMPOSITED but give me problems with WM_MOUSEMOVE message :(
someone tell me something about double-buffering, but i only knows use it for images and not controls :(
please can anyone explain to me something? please?

cambalinho 142 Practically a Posting Shark

heres the code more fixed and indented:

#include<iostream>
#include<conio.h>
#include <stdlib.h>

using namespace std; //or you use these line or you must do std::cout or std::cin

int s[10]={0,0,0,0,0,0,0,0,0,0}, top=-1, o=0;

//never forget the C\C++ read the code from top to bottom, so the functions order are important
void DisplayStack()
{
    int i=0;//1 variable not inicializated have random values(whtat is in memory)
    cout<<"Contents:";
    for(i=0;i<=top;i++)//whereis the 'if'????
        cout<<"s[i]"<<"  ";
    else
        cout<<"Stack Empty\n";
}

void CreateStack()
{
    int i=0;
    top=-1;
    for(i=0;i<=9;i++)
        s[i]=0;
    cout<<"Stack Created\n";
    getch();
}

int IsFull()
{
    if(top==9)
        return 1;
    else
        return 0;
}

int IsEmpty()
{
    if (top==-1)
        return 1;
    else
        return 0;
}

void push(int x)
{
    if(!IsFull())
    {
        top ++;
        s[top]=x;
        DisplayStack();
    }
    else
        cout<<"Stack Full\n";
}

void PushStack()
{
    int n=0;
    cout<<"Enter item to Add";
    cin>>n;
    push(n);
    getch();
}

void PopStack()
{
    if(!IsEmpty())
    {
        top--;
        DisplayStack();
    }
    else
        cout<<"Stack Empty\n";
    getch();
}

void TopStack()
{
    cout<<"Top of Stack:"<<s[top]<<"n";
    getch();
}

void CheckEmpty()
{
    if(IsEmpty())
        cout<<"Stack Empty\n";
    else
        DisplayStack();
    getch();
}

void CheckFull()
{
    if(IsFull())
        cout<<"Stack Full\n";
    else
        DisplayStack();
    getch();
}

void GetSize()
{
    cout<<"No. of elements"<<top+1<<"\n";
    getch();
}

//the main must have a return type even if is void
int main()
{
    while(o!=9)//i think these is better for a menu
    {
        system("cls");//there isn't a clrscr() function, only on olders compilers like Turbo C\C++
        cout<<"Options\n";
        cout<<"[1]Create\n";
        cout<<"[2]Push\n";
        cout<<"[3]Pop\n";
        cout<<"[4]Top\n";
        cout<<"[5]IsEmpty\n";
        cout<<"[6]IsFull\n";
        cout<<"[7]GetSize\n";
        cout<<"[8]DisplayContents\n";
        cout<<"[9]Exit\n";
        cout<<"Enter Choice:";
        cin>>o;

        //i changed these if
        if(o==1)
            CreateStack();
        else if(o==2)
            PushStack();
        else if(o==3)
            PopStack();
        else if(o==4)
            TopStack();
        else if(o==5)
            CheckEmpty();
        else if(o==6) …
cambalinho 142 Practically a Posting Shark

sorry Moschops, but he can't execute the code, because of several errors ;)

cambalinho 142 Practically a Posting Shark

for now, i have seen several errors:
1 - cout is from std namespace, so after #includes use: using namespace std;
2 - you use a function before create it: DisplayStack(), put these function before is used. i know what you mean, but C\C++ do these by order.
3 - where is the 'if', if you use the 'else', you must use the 'if':

void DisplayStack()

      { int i;
            cout<<"Contents:";


               for(i=0;i<=top;i++)
            cout<<"s[i]"<<"  ";
               else
         cout<<"Stack Empty\n";

         }

4 - theres isn't clrscr() sorry. only in Turbo IDE and conio2.h or something.
but you can use:

system("cls");

and add: #include <stdlib.h>

5 - the main must return a value so:
returntype main()

int main()

you return a value but you didn't said the type to the compiler ;)

please correct these function: DisplayStack()... because we don't know what you want ;)

cambalinho 142 Practically a Posting Shark

i did an Empty project(bored... only problems :( ). but can i add a manifest file to exe or the project?

cambalinho 142 Practically a Posting Shark

anotherthing: if we use DT_EXPANDTABS with DT_CALCRECT, the rectangle size include the tab size too:

DrawText(GetDC(hwnd), a, strlen(a), &c, DT_CALCRECT | DT_EXPANDTABS);

sorry.. it's give me much more big than i need :(

cambalinho 142 Practically a Posting Shark

thanks for all.
but can i avoid the '+2'???(i think, depending on fontsize or even anotherthing, the '+2' can be less than we need)

cambalinho 142 Practically a Posting Shark

i did a new search i did these code:

void setAutoSize(bool autosize)
    {
        if (autosize==true)
        {
            char a[256];
            GetWindowText(this->hwnd,a,256);
            RECT c = { 0, 0, 0, 0 };            
            DrawText(GetDC(hwnd), a, strlen(a), &c, DT_CALCRECT);
            LONG s=GetWindowLongPtr(hwnd,GWL_EXSTYLE);
            LONG g=GetWindowLongPtr(hwnd,GWL_STYLE);
            AdjustWindowRectEx (&c,g,FALSE,s );
            SetWindowPos(hwnd, 0, 0, 0, c.right+2, c.bottom+2,
            SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE|
            SWP_DRAWFRAME | SWP_FRAMECHANGED);
        }
    }

but i see 2 problems:
1 - the "\t" is ignored;
2 - i must add '+2'... why? for show the last character correctly.

what you can tell me about these?

cambalinho 142 Practically a Posting Shark

sorry SalmiSoft, but i'm very confuse:(
because i only know that the DrawText() is for show us a text on control\hdc.
so please give me more information

cambalinho 142 Practically a Posting Shark

i know use the some functions for put an image on window:

void setImage(string FileName)
    {
        HBITMAP hImage =(HBITMAP) LoadImage(NULL,FileName.c_str(),IMAGE_BITMAP,20,20,LR_LOADFROMFILE);
        HDC image = CreateCompatibleDC(NULL);
        SelectObject(image,hImage);
        BITMAP bitmap;
        GetObject(hImage,sizeof(BITMAP),&bitmap);
        BitBlt(GetDC(this->hwnd),0,0,bitmap.bmWidth,bitmap.bmHeight,image,0,0,SRCCOPY);
    }

but i get 2 problems:
1 - the image isn't showed with original size :( ;
2 - after 2 seconds, i loose the image :(

without using the WM_PAINT how can i add an image to a window and be persistence?
can i use the SendMessage() for resolve the problem?

cambalinho 142 Practically a Posting Shark

imagine the text is more big than control. i want resize the control until see the text. i use the:
- GetWindowText() for get the text;
- SendMessage() for get the font and then select the object;
- GetTextExtentPoint32() for get the font lengh in pixels;
- GetWindowRect() for get the window position(and size);
- GetWindowLongPtr() for get the Styles and Extended Styles;
- AdjustWindowRectEx() for get the control size with borders;
- SetWindowPos() for change the window size.
these code works fine, but imagine that the text have '\t' or '\n', by some reason these code didn't work for the right size. but if is just a single text line and without '\t', works fine.
what you can advice me, please?

cambalinho 142 Practically a Posting Shark

the IDE was tell me these line was an error:

 m_cn.ConnectionString = "Data Source=.\SQLEXPRESS; AttachDbFilename = " & _
"C:\ManutencaoDeAutomoveis\ManutencaoDeAutomoveis\Database1.mdf; " & _
"Integrated Security=True; Connect Timeout=30;" & "User Instance=True"

but isn't correct. that line it's ok.. the problem was here:

Public m_DataRow As DataRow = m_DataTable.Rows(0)

how can i inicializate that variable without know what table is :)
after fix that line, the problem was resolved too ;)
thanks for all

cambalinho 142 Practically a Posting Shark

using API functions, can i get the text rectangule?

cambalinho 142 Practically a Posting Shark

i'm building a data base.. heres what i did:
1 - create the forms and put the controls;
2 - create the Service-base DataBase(add New Item);
3 - a toolbox, on left, is showed and then i create a new table;
4 - using the mouse right button, i select(on menu) Show Table Data for add the new elements.
and now heres the code:
Module:

Imports System.Data.SqlClient

Module Module1
    Public cnADONetConnection As New SqlConnection()
    Public m_cn As New SqlConnection()
    Public m_DA As SqlDataAdapter
    Public m_CB As SqlCommandBuilder
    Public m_DataTable As New DataTable
    Public m_rowPosition As Integer = 0
    Public m_DataRow As DataRow = m_DataTable.Rows(0)


End Module

on form1(where are the menus):

Imports System.Data.SqlClient

Public Class frmMenu

    Private Sub lblAdicionarVeiculo_Click(sender As System.Object, e As System.EventArgs) Handles lblAdicionarVeiculo.Click
        frmInserirDadosVeiculo.ShowDialog()
    End Sub

    Private Sub lblEditarVeiculo_Click(sender As System.Object, e As System.EventArgs) Handles lblEditarVeiculo.Click
        Search.ShowDialog()
    End Sub

    Private Sub lblApagarVeiculo_Click(sender As System.Object, e As System.EventArgs) Handles lblApagarVeiculo.Click
        Search.ShowDialog()
    End Sub

    Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
        End
    End Sub

    Private Sub frmMenu_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        m_cn.ConnectionString = "Data Source=.\SQLEXPRESS; AttachDbFilename = " & _
"C:\ManutencaoDeAutomoveis\ManutencaoDeAutomoveis\Database1.mdf; " & _
"Integrated Security=True; Connect Timeout=30;" & "User Instance=True"
        m_cn.Open()
        m_DA = New SqlDataAdapter("Select * From Manutencao", m_cn)
        m_CB = New SqlCommandBuilder(m_DA)
        m_DA.Fill(m_DataTable)

    End Sub
End Class

and the form2:

Public Class frmInserirDadosVeiculo

    Private Sub ShowCurrentRecord()
        If m_DataTable.Rows.Count > 0 Then
            txtMarcaModelo.Text = _
        m_DataTable.Rows(m_rowPosition)("IDMarcaModelo").ToString()
            txtMatricula.Text = _
            m_DataTable.Rows(m_rowPosition)("IDMatricula").ToString()
        End …
cambalinho 142 Practically a Posting Shark

show us your code please

cambalinho 142 Practically a Posting Shark

so it's only valid for form(main window)?

cambalinho 142 Practically a Posting Shark

i never use ubuntu. so i let for another person ;)

cambalinho 142 Practically a Posting Shark

sorry, i can't find your answer.. sorry.
but, maybe, you just include the directx header files...
see these book: http://www.amazon.com/Beginning-Game-Programming-Jonathan-Harbour/dp/1435454278
and maybe you find some examples and then you see if you have the header files.
sorry if i don't help you much, but you a point to start

najiawad0 commented: thanx :) but do u know if i should get ubuntu? +0
cambalinho 142 Practically a Posting Shark

sorry.. same error :(
the clrBackColor it's COLORREF

cambalinho 142 Practically a Posting Shark

najiawad0: you answer in wrong place, but thanks for the vote ;)
you tell me that you love programming, in these case, the C++ and that you use mac. my question is: what IDE you use now?

najiawad0 commented: I use Xcode for C++ +0
cambalinho 142 Practically a Posting Shark

learn directx for c++:http://www.youtube.com/watch?v=0kpSiitk4eI

but if you are using Visual Studio, you can learn XNA: http://www.youtube.com/watch?v=yi167gMOi-I

and you need learn Game Design Theory and Practice: http://www.amazon.com/Game-Design-Practice-Wordware-Developers/dp/1556229127

najiawad0 commented: I use a mac, is there any IDE that has directx? +0
cambalinho 142 Practically a Posting Shark

from VB6, i build these code for transparent:

void Transparent()
    {
        SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
        SetLayeredWindowAttributes (hwnd, clrBackColor, 0, LWA_COLORKEY);
        const char *text;
        text=to_string( GetLastError()).c_str();
        MessageBox(NULL,text,"erro",MB_OK);
    }

but i get 1 error from messagebox:
87:ERROR_INVALID_PARAMETER - The parameter is incorrect.

can anyone advice me?

cambalinho 142 Practically a Posting Shark
cambalinho 142 Practically a Posting Shark

how can i get the font of a control?
for i change what i need and then select it

cambalinho 142 Practically a Posting Shark

thanks for share that code.
let me ask 1 thing: what WM_PAINT have to do with mouse messages?
(why the question? because when i used the WM_PAINT, seems the mouse message aren't working)

cambalinho 142 Practically a Posting Shark

now i know why the code isn't working, because i'm using a Window Procedure Super Class.
the control procedure is inside of class... how can i change the code for works with my situation?

cambalinho 142 Practically a Posting Shark

but the mouse messages aren't working... why?

cambalinho 142 Practically a Posting Shark

it's like draw my own label inside of label control, right?
(put a border, background color, text(with TextOutA() instead SetWindowText()), images and more)

cambalinho 142 Practically a Posting Shark

triumphost: i'm trying understand your code for i change it :(

cambalinho 142 Practically a Posting Shark

i only have 1 question: these is realyv drawed in the STATIC control or the window?
why the question? because the text is drawed out of the static position and size

cambalinho 142 Practically a Posting Shark

forget that lines.. and tell me what i realy need to do for change the colors

cambalinho 142 Practically a Posting Shark

ok... thanks
remember the class is in Label.h and the rest is in main.cpp.
i had share the entire code in post 6.

cambalinho 142 Practically a Posting Shark

if i use SetSysColors() i can't tell it the hwnd or hdc.
sorry, we are 'in same page'?
my class creates the STATIC control. with SetWindowText() i change it's caption(not title bar window). now i need change the backcolor and text color of the STATIC caption

cambalinho 142 Practically a Posting Shark

sorry??? the SetWindowText() it's the static capion, in these case

cambalinho 142 Practically a Posting Shark

sorry... realy.. i continue confuse :(
my problem isn't use your code, the problem is the code that don't do the job :(

heres the Label.h

#include <windows.h>
#include <string>
#include <functional>
#define event(eventname, ... ) std::function<void(__VA_ARGS__ )> eventname

using namespace std;

const char *labelpropname = "Cambalinho";
const char *labelclassprop = "classaddr";

enum MouseButtons
{
    None=-1,
    Left=0,
    Right=1,
    Middle=2,
    X1=3,
    X2=4
};

struct Position
{
    int X;
    int Y;
};

struct Size
{
    int Width;
    int Height;
};

class label
{
private:
    HWND hwnd;
    WNDCLASS wc;
    void TrackMouse(HWND hwnd)
    {
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(TRACKMOUSEEVENT);
        tme.dwFlags = TME_HOVER | TME_LEAVE; //Type of events to track & trigger.
        tme.dwHoverTime = 5000; //How long the mouse has to be in the window to trigger a hover event.
        tme.hwndTrack = hwnd;
        TrackMouseEvent(&tme);
    }

    static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        WNDPROC oldproc = (WNDPROC)GetProp(GetParent(hwnd), labelpropname);
        label *inst = (label*)GetProp(GetParent(hwnd), labelclassprop);

        if (oldproc == NULL || inst == NULL)
            MessageBox(NULL, "null", "null", MB_OK);

        static bool TrackingMouse = false;
        static bool WindowStopMoving = NULL;
        static bool WindowStopResize = NULL;
        static const UINT_PTR MouseStopTimerID = 1;
        static HBRUSH hBrush = CreateSolidBrush(RGB(230,230,230));

        switch(msg)
        {

            case WM_CREATE:
            {
                static int xPos = (int)(short) LOWORD(lParam);
                static int yPos = (int)(short) HIWORD(lParam);
                inst->Create(xPos,yPos);
            }
            break;

case WM_PAINT:
{
    HBRUSH pForeground =(HBRUSH) RGB(0,255,0);
HBRUSH pBackground =(HBRUSH) RGB(255,0,0);

    PAINTSTRUCT ps;
HDC hdc = BeginPaint(inst->hwnd, &ps);
static COLORREF backcolor=(COLORREF) pForeground;
// TODO: Add any drawing code here...
SetBkColor(hdc,backcolor);
SetBkMode(hdc,TRANSPARENT);
SetWindowText(inst->hwnd,"hello");
EndPaint(inst->hwnd, &ps);
}
    break;

            case WM_MOVE: …
cambalinho 142 Practically a Posting Shark

i even try these:

case WM_PAINT:
{

    PAINTSTRUCT  ps;
    HDC hdc = BeginPaint(inst->hwnd, &ps);
    static COLORREF backcolor= RGB(0,255,0);
    // TODO: Add any drawing code here...
    SetBkColor(hdc,backcolor);
    SetBkMode(hdc,TRANSPARENT);
    SetWindowText(inst->hwnd,"hello");
    EndPaint(inst->hwnd, &ps);
}
    break;

or the hwnd or even the hdc aren't correct or i don't know :(

cambalinho 142 Practically a Posting Shark

Happy a new year!!!
can you show me please?
anotherthing: why i can't build a function(inside the class) for change it directly?

cambalinho 142 Practically a Posting Shark

i build a class for create a static control(label). and i't cool. but why the SetTextColor() and SetBkColor() are ignored?

case WM_PAINT:
{

    PAINTSTRUCT  ps;
    HDC hdc = BeginPaint(inst->hwnd, &ps);
    // TODO: Add any drawing code here...
    SetBkColor(hdc, RGB(0,255,0));
    SetBkMode(hdc,TRANSPARENT);
    SetWindowText(inst->hwnd,"hello");
    EndPaint(inst->hwnd, &ps);
}

the inst is the class(label) pointer instance.
by some reason is ignored and i don't understand why :(
can anyone dvice me, please?

cambalinho 142 Practically a Posting Shark

ok.. now works cool(with some help):

#include <windows.h>
#include <string>
#include <functional>
#define event(eventname, ... ) std::function<void(__VA_ARGS__ )> eventname

using namespace std;

const char *labelpropname = "Cambalinho";
const char *labelclassprop = "classaddr";

struct Position
{
    int X;
    int Y;
};

struct Size
{
    int Width;
    int Height;
};

class label
{
private:
    HWND hwnd;

    static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        WNDPROC oldproc = (WNDPROC)GetProp(GetParent(hwnd), labelpropname);

        label *inst = (label*)GetProp(GetParent(hwnd), labelclassprop);

        if (oldproc == NULL)
            MessageBox(NULL, "null", "null", MB_OK);


        switch(msg)
        {

            case WM_MOVE:
            {
                static int xPos = (int)(short) LOWORD(lParam);
                static int yPos = (int)(short) HIWORD(lParam);
                inst->Move(xPos,yPos);//why these line make my progra, give me an error for get support? :(
            }
            break;
            case WM_NCHITTEST:
                return DefWindowProc(hwnd, msg, wParam, lParam);

            case WM_LBUTTONUP:
                SetFocus(inst->hwnd);
                inst->SetText("Left mouse button up");
            break;

            case WM_MOUSEMOVE:
                inst->SetText("mouse move");

            break;

            case WM_KEYUP:

                inst->SetText(to_string(wParam));
            break;

                default:
            break;
        }

        return oldproc ? CallWindowProc(oldproc, hwnd, msg, wParam, lParam) : DefWindowProc(hwnd, msg, wParam, lParam);
    }

public:

    //is these 2 lines ok?
    //see the #define on top
    event(Create,(int x, int y));
    event(Move,(int x, int y));
    ~label()
    {
        DestroyWindow(hwnd);
        hwnd = 0;
    }

    label(HWND parent)
    {

        WNDCLASS wc;
        HINSTANCE mod = (HINSTANCE)GetModuleHandle(NULL);

        ZeroMemory(&wc, sizeof(WNDCLASS));
        GetClassInfo(mod, "STATIC", &wc);

        wc.hInstance = mod;
        wc.lpszClassName = "CSTATIC";

        // store the old WNDPROC of the EDIT window class
        SetProp(parent, labelpropname, (HANDLE)wc.lpfnWndProc);
        SetProp(parent, labelclassprop, (HANDLE)this);

        // replace it with local WNDPROC
        wc.lpfnWndProc = WndProc;

        // register the new window class, "ShEdit"
        if (!RegisterClass(&wc))
            MessageBox(NULL, "error in register", "error", MB_OK);

        hwnd = CreateWindowEx(
            WS_EX_LEFT| WS_EX_LTRREADING …
cambalinho 142 Practically a Posting Shark

i'm building the label1 class, but i'm getting bad results... so i ask: how can i use the SetWindowLongPtr() for use a window procedure?
(i can show the label and change it's properties... but i'm getting problems for active it's own window procedure :( )
see the entire code\class:

#include <windows.h>
#include <iostream>
#include <string>
#include <process.h>

using namespace std;
HWND hwnd;
HHOOK _hook;
LRESULT __stdcall HookCallback(int nCode, WPARAM wParam, LPARAM lParam)
{
    if (nCode >= 0)
    {
        // the action is valid: HC_ACTION.
        if (wParam == WM_LBUTTONUP)
        {
            MessageBox(NULL, "hi","hello",MB_OK);
        }
    }
   return CallNextHookEx(NULL, nCode, wParam, lParam);
}

class label
{
private:





public:

    label(HWND value)
    {

        hwnd = CreateWindowEx(
            WS_EX_LEFT| WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
            "STATIC",
            "hello world",
            SS_LEFT|WS_CHILD|WS_VISIBLE,
            0, 0, 100, 100,
            value,
            NULL,
            GetModuleHandle(NULL),
            NULL);
            SetWindowsHookEx(WH_CALLWNDPROC, HookCallback, NULL, 0);
            ShowWindow(hwnd,SW_SHOW);
            UpdateWindow(hwnd);
    }

    COORD GetSize()
    {
        RECT LabelSize;
        GetWindowRect(hwnd,&LabelSize);
        COORD crdSize={LabelSize.right-LabelSize.left,LabelSize.bottom-LabelSize.top};
        return crdSize;
    }

    void SetText(string text)
    {
        char* chrText=(char*)text.c_str();
        SetWindowText(hwnd, chrText);
    }


};

i'm trying connect the STATIC class with my own window procedure....
please some one give me more info
anotherthing: why i can't put the window procedure inside of the class?

cambalinho 142 Practically a Posting Shark

http://www.cplusplus.com/forum/windows/39170/
but learn more about recursive functions
don't forget the recursive functions are functions that call them selfs, never forget put an if for close them or it can takes several memory or even more problems

cambalinho 142 Practically a Posting Shark

it's C programming language with class's, templates and more

cambalinho 142 Practically a Posting Shark

thanks for that. now tell me why the char* isn't working?

int main()
{
    char *c="hello";
    Variant a=c;
    cout << a;
    return 0;
}

tell me:
"error: call of overloaded 'to_string(char&)' is ambiguous"
i understand that means that i can't convert char
to string... like saying it's the same type... so please correct me