cambalinho 142 Practically a Posting Shark

maybe you have right... but, for now, i don't understand why and where i'm fail :(
i'm learning from: https://permadi.com/1996/05/ray-casting-tutorial-table-of-contents/
theres several tutorials, but not all are so good :(

rproffitt commented: When you break on the line that does the math, it's back to you to determine if the number is what you expected. +0
cambalinho 142 Practically a Posting Shark

will be rounded numbers problem or something?
yes i'm testing more, but no success :(

rproffitt commented: It's your math, not mine as well as you seeing the numbers in the debugger which I can't see. Sorry. +17
cambalinho 142 Practically a Posting Shark

these is the VB6 function for RayCasting:

Private Sub DrawRays()

        Dim StepX As Double
        Dim StepY As Double
        Dim VertX As Double
        Dim VertY As Double
        Dim HorizX As Double
        Dim HorizY As Double
        Dim MapX As Long
        Dim MapY As Long
        Dim HorizDist As Double
        Dim VertDist As Double
        Dim WallDistance As Double
        Dim RayHeight As Double
        Dim RayRadians As Double
        Dim RadiansSteps As Double
        Dim RayCount As Long
        Dim RayCounts As Long
        Dim OffSetGrid As Long


        RayCount = imgverticalline.Width

        MapX = Player.MapX
        MapY = Player.MapY
        RadiansSteps = Radian60 / RayCount

        RayRadians = (Player.Radians - Radian30)
        RayCounts = 0
        Do While RayCounts < RayCount
            If (RayRadians > Radian360) Then RayRadians = 0.001
            'Check for horizontal intersections:

            If RayRadians >= 0 And RayRadians <= Math.PI Then 'Facing down
                HorizY = (Fix(player.PosY / ObjectSize) * ObjectSize) + ObjectSize ' Calculate grid position
                HorizX = player.PosX + (HorizY - player.PosY) / Math.Tan(RayRadians)
                StepY = ObjectSize
            ElseIf RayRadians = 0 Or RayRadians = Math.PI Then
                HorizY = player.PosY
                HorizX = player.PosX
            Else 'Facing Up
                HorizY = (Fix(player.PosY / ObjectSize) * ObjectSize) - 1
                HorizX = player.PosX + (HorizY - player.PosY) / Math.Tan(RayRadians)
                StepY = -ObjectSize
            End If

            StepX = StepY / Math.Tan(RayRadians)
            MapX = GetPositionMap(HorizX)
            MapY = GetPositionMap(HorizY)



            Do
                If MapX < 0 Or MapX > 9 Or MapY < 0 Or MapY > 9 Then Exit Do
                If levelmap0(MapY, MapX) = Color.Black Then Exit Do
                HorizX = HorizX + StepX
                HorizY = HorizY + StepY

                MapX = GetPositionMap(HorizX)
                MapY = GetPositionMap(HorizY)

            Loop …
cambalinho 142 Practically a Posting Shark

correct me: the Bitmaps.lockbits() and Bitmaps.unlockbits(), for change the pixels(all pixels), are more faster or like DIB's speed or more slow?

rproffitt commented: Reminder: I don't have older Visual Studio versions installed now. Only VS2022 available. +0
cambalinho 142 Practically a Posting Shark

that link\tutorial have some errors: VB2010 don't have the 'any' type

rproffitt commented: Never has. That's why we use the .NET examples. +17
cambalinho 142 Practically a Posting Shark

How use and declare CopyMemory() API function VB2010?

cambalinho 142 Practically a Posting Shark

how can i convert cursor files to image?
i need see the cur\ani on picturebox?(just for learning)

Private Sub btnChooseImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChooseImage.Click
        If (ofdChooseFile.ShowDialog = Windows.Forms.DialogResult.OK) Then
            If (ofdChooseFile.FilterIndex = 6) Then
                Dim cur As New Cursor(ofdChooseFile.FileName)
                PicShowImage.Image = cur 'error yes
            Else
                PicShowImage.Image = Image.FromFile(ofdChooseFile.FileName)
            End If
            Me.Text = "Image Viewer: " & ofdChooseFile.FileName
        End If
    End Sub

how can i get the image from a cursor?
the Cursor object read cur files and ani?

cambalinho 142 Practically a Posting Shark

how can i convert these C line:

(py>>6)<<6)

to VB6?

cambalinho 142 Practically a Posting Shark

after several tests i fix it:

Do While RayCounts < RayCount
        If (RayRadians > (2 * PI)) Then RayRadians = 0.001

i have more to update:
1 - win more performance\FPS;
2 - and trying avoid the 'on error resume next'(it's about the array dimensions):

Private Sub DrawRays2()

    Dim AY As Double
    Dim AX As Double
    Dim StepX As Double
    Dim StepY As Double
    Dim VertX As Double
    Dim VertY As Double
    Dim HorizX As Double
    Dim HorizY As Double
    Dim MapX As Long
    Dim MapY As Long
    Dim HorizDist As Double
    Dim VertDist As Double
    Dim WallDistance As Double
    Dim RayHeight As Double
    Dim RayRadians As Double
    Dim RadiansSteps As Double
    Dim RayCount As Integer
    Dim RayCounts As Integer
    RayCount = 320

    MapX = Player.MapX
    MapY = Player.MapY
    RadiansSteps = Radian60 / 320

    On Error Resume Next
    RayRadians = (Player.Radians - Radian30)
    RayCounts = 0
    Do While RayCounts < RayCount
        If (RayRadians > (2 * PI)) Then RayRadians = 0.001
        'Check for horizontal intersections:
        If RayRadians > 0 And RayRadians < PI Then 'Facing down

thanks for all

cambalinho 142 Practically a Posting Shark

finally i found the problem is on these line:

HorizDist = Sqr(((HorizX - Player.PosX) * (HorizX - Player.PosX)) + ((HorizY - Player.PosY) * (HorizY - Player.PosY))) 'works fine




VertDist = Sqr(((VertX - Player.PosX)) * ((VertX - Player.PosX))) + (((VertY - Player.PosY)) * ((VertY - Player.PosY)))'calculation incorrect

like you see the problem was the calculation order(or signal inverted)...
now works fine...
i need correct another calculation after these:

    WallDistance = WallDistance * Cos(Player.Radians) 'avoiding the Fish Effect.. works correctly
    RayHeight = ObjectSize / WallDistance * 320 '320 is the width screen... is for get the height of vertical line 
    A.ForeColor vbBlue
    A.DrawLine 475 + 50, 200 / 2 - RayHeight / 2, 475 + 50, 200 / 2 + RayHeight / 2 '200 is the Height screen
    '475 + 50 is where it must be drawed

like you see i get the Height vertical line... but theres a problem, because the 200 is the max... but i can get more when i'm too close :(
how can i fix these calculation?

rproffitt commented: Let's say 200 is the max value, you can code it to limit it to 200. +17
cambalinho 142 Practically a Posting Shark

heres my RayCasting function:

Private Sub DrawRays2()
    Dim AY As Double
    Dim AX As Double
    Dim StepX As Double
    Dim StepY As Double
    Dim VertX As Double
    Dim VertY As Double
    Dim HorizX As Double
    Dim HorizY As Double
    Dim MapX As Long
    Dim MapY As Long
    Dim HorizDist As Double
    Dim VertDist As Double
    Dim WallDistance As Double
    Dim RayHeight As Double

    MapX = Player.MapX
    MapY = Player.MapY
    On Error Resume Next

'    'Check for horizontal intersections:
    If ((Player.Radians > 0 And Player.Radians < PI)) Then 'Facing down
        AY = (Int(Player.PosY / ObjectSize) * ObjectSize) + ObjectSize ' Calculate grid position
        AX = Player.PosX + (AY - Player.PosY) / Tan(Player.Radians)
        StepY = ObjectSize
    ElseIf ((Player.Radians = 0 And Player.Radians = PI)) Then
        AY = Player.PosY
        AX = Player.PosX
    Else 'Facing Up
        AY = (Int(Player.PosY / ObjectSize) * ObjectSize) - 1
        AX = Player.PosX + (AY - Player.PosY) / Tan(Player.Radians)
        StepY = -ObjectSize
    End If


    HorizX = AX
    HorizY = AY
    StepX = StepY / Tan(Player.Radians)
    MapX = Fix((HorizX) / ObjectSize)
    MapY = Fix((HorizY) / ObjectSize)
    A.SetPixel (Fix(HorizX)), (Fix(HorizY)), ColorConstants.vbCyan
    If LevelMap0(MapY, MapX) <> vbBlue Then

        Do

            HorizX = HorizX + StepX
            HorizY = HorizY + StepY

            MapX = Fix((HorizX) / ObjectSize)
            MapY = Fix((HorizY) / ObjectSize)
            A.SetPixel (Fix(HorizX)), (Fix(HorizY)), ColorConstants.vbCyan
            If LevelMap0(MapY, MapX) = vbBlue Then
                Exit Do
            End If
            DoEvents
        Loop
    End If


    HorizDist = Sqr(((HorizX - Player.PosX) * (HorizX - Player.PosX)) + ((HorizY - Player.PosY) * (HorizY - Player.PosY)))


    'Check for vertical intersections:
    If ((Player.Radians < PI …
cambalinho 142 Practically a Posting Shark

i was avoiding the overflow.... but the problem is much more than the data type... and it's only on Alpha element... but finally seems fixed:

Public Function ARGB(ByVal alpha As Byte, ByVal red As Byte, ByVal green As Byte, ByVal blue As Byte) As Long
    '1st testing the Alpha element:
    ARGB = (alpha And &H7F) * &H1000000 Or -((alpha And &H80) <> 0) * &H80000000 _
        Or red * &H10000 _
        Or green * &H100& _
        Or blue
End Function

thank you so much for all

cambalinho 142 Practically a Posting Shark

i need optimization, because i only have 200FPS for change 1 color.. these is a test for change the Alpha values... i can share all code

rproffitt commented: The code provided shows it is not optimized. See my comments. +17
cambalinho 142 Practically a Posting Shark

finally i speed up my code severy:

Friend Sub DrawImagePlanePoints(DestinationHDC As Long, Points() As Position3D, WorldSize As Size3D, Optional ByVal Opacity As Long = 255)
    'Points(0) is the Upper-Left
    'Points(1) is the Upper-Right
    'Points(2) is the Low-Right
    'Points(3) is the Low-Left

    'Testing if we have image before we use it:
    If (hBitmap = 0 Or hMemDC = 0) Then Exit Sub

    'Get left and right vertical line points:
    Dim PointsUpperDownLeft() As Position3D
    PointsUpperDownLeft = GetLinePoints(Points(0), Points(3))
    Dim PointsUpperDownRight() As Position3D
    PointsUpperDownRight = GetLinePoints(Points(1), Points(2))

    'Between the left and right vertical line points we get the horizontal line points:
    Dim OriginPoint As POINTAPI
    Dim DestinationPoint As POINTAPI

    'Draw Horizontal image line from vertical plane lines:
    Dim y As Long
    Dim PosX As Long
    Dim PosY As Long

    For y = 0 To UBound(PointsUpperDownLeft) - 1

        OriginPoint = ConvertPositon3DTo2D(PointsUpperDownLeft(y), WorldSize)
        DestinationPoint = ConvertPositon3DTo2D(PointsUpperDownRight(y), WorldSize)


        PosY = y
        If (PosY >= (Height)) Then
            While (PosY > (Height - 1))
                PosY = PosY - Height
            Wend
        End If
        AlphaBlend DestinationHDC, OriginPoint.x, OriginPoint.y, DestinationPoint.x - OriginPoint.x, 1, hMemDC, 0, PosY, Width, 1, AC_SRC_ALPHA * &H1000000 + Opacity * &H10000
    Next y
End Sub

now the image can be drawed transparency.... and i can, too, make 1 color transparent, changing the alpha value.
using the image size, i can tile it too ;)
thanks for all

cambalinho 142 Practically a Posting Shark

"PS. If the discussion title is changed I must remove some of my answers as they would no longer apply. My vote is to leave the title as-is. My suggestion is that you work on your other post where the code was revealed as well as discuss and reveal what the host PC looks like. Sometimes I've run into developers that are on decade plus old dual core PCs with onboard graphics. We try their app on one of our office dev systems and the performance is fine."
now i can't edit it... moderator maybe see these next message.

"How do you know the U and L bound calls are the speed hits here and not the more usual areas? Did you profile and measure the times spent on each operation?"
i don't know.. but i win severy speed.... but i need more help.... so i will create a new topic ;)

cambalinho 142 Practically a Posting Shark

let me ask 2 things:
1 - i never used Directx, but it's best start 8 or 9 version?(yes i can use both on my VB6)
yes Directx seems a little complex, so i must start from begining until i start it ;)
2 - why the GDI and GDI+ functions don't use GPU?
Moderator: please change the topic title to "VB6: how we get more speed on Graphics?"

rproffitt commented: Your other post is about that indirectly. Here, you lead with something else. +15
cambalinho 142 Practically a Posting Shark

to be honest i'm sorry something... i did that by 1 reason, but not all agree with it :(
i'm trying learning what i can about it, but isn't easy... and i'm not on school\university.... i'm learning these area by me and start(i repeat) start without a big book(hundreds or thousdans pages)... after that i'm more close to understand the book(English... i'm Portuguese.
i'm sorry something but isn't for be rude... sometimes isn't easy

rproffitt commented: You're doing fine. +15
cambalinho 142 Practically a Posting Shark

seen some tutorials i found the Z-order and test if i need draw the line or not:
http://www.ece.ubc.ca/~saifz/eece478/course/hidden.pdf
but i need more: imagine if the plane is more big than the camera, how can i draw it?

cambalinho 142 Practically a Posting Shark
  • i run my compiled program;
  • the program is executed without a problem..
  • when i create(from my program) the text file, the WD delete my text file.
    the text file is only for get C++ code lines... nothing more.

Reverend Jim: "As I said before, typically UAC intercepts any attemots to write to protected folders."
if i use a resource file with name version and more(speaking about my compiled program), will resolve the problem?

rproffitt commented: Please tell a lot more. It hampers getting to what's going on. And no. +15
cambalinho 142 Practically a Posting Shark

ok maybe you have right.. i'm using on my Documents folder... the text file is created close the exe file... and maybe you have right about it.
just for test: what folders i can use without WD don't complain?

cambalinho 142 Practically a Posting Shark

Husoski: using

scanf("%255s", opinions);

accept space\tab too?

Husoski commented: No, %s scanning stops on any whitespace, not just a newline. Use %255[^\n] to include any character except a newline. +0
cambalinho 142 Practically a Posting Shark

i installed a worked driver.... but the windows 10 update it automatic and now isn't working :(

cambalinho 142 Practically a Posting Shark

thank you so much for all to all

rproffitt commented: It's all your work above. +1 +15
cambalinho 142 Practically a Posting Shark

i need speak ;)
everytime that i create a topic, i recive an email... jonh_165 you can test that...
now the notifications can have a delay, but they will be showed... i use hotmail.
anotherthing: when you are login, maybe, you don't recive the notifications...
ok, i'm sepaking by head, but these is more or less what i see.
but Dani has right, the hotmail is more strange for get the mails. i have problems on others pages\forums too. it's a hotmail bug. you can try speak with them for see what that say, but.. i don't know what they will answer and you don't understand more.
Dani do what she can... but somethings aren't from here, but the hotmail 'rules'. i had some problems and she helped me very.
thank you so much for all
hey Happy Chrismas

cambalinho 142 Practically a Posting Shark

heres my actual code for find\search a folder:

string FindDirectory(std::string FindDirectoryName[2], std::string StartDirectory="C:")
{
    WIN32_FIND_DATA file={0};
    string str=StartDirectory+ "\\*";
    HANDLE search_handle = FindFirstFile(str.c_str(), &file);
    static bool blnFindDirectoryName=false;
    static string strFolderName ="";

    //testing if the folder is valid:
    if (search_handle != INVALID_HANDLE_VALUE)
    {
        do
        {
            //if the folder was founded, then break the loop:
            if(strFolderName!="")
                break;

            //for avoid files names and the folders "." and "..":
            if ((file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strcmp(file.cFileName, "..") && strcmp(file.cFileName, "."))
            {
                //cout <<StartDirectory + "\\" + file.cFileName << endl;

                //testing if the folder was found
                //and add it on static strFolderName
                if(string(file.cFileName)==FindDirectoryName[0] && blnFindDirectoryName==false)
                {
                    if(FindDirectoryName[1]=="")
                    {
                        strFolderName = StartDirectory+ "\\" + file.cFileName;
                        break;
                    }
                    else
                        blnFindDirectoryName=true;
                }
                if(string(file.cFileName)==FindDirectoryName[1] && blnFindDirectoryName==true)
                {
                    //MessageBox(NULL, string(StartDirectory+ "\\" + file.cFileName).c_str(), "found it", MB_OK);
                    strFolderName = StartDirectory+ "\\" + file.cFileName;
                    break;
                }
                else
                {
                    //or continue searching:
                    FindDirectory(FindDirectoryName,StartDirectory + "\\" + file.cFileName);
                }
            }
        } while (FindNextFile(search_handle, &file) && search_handle!=NULL);
        //destroy the search_handle:
        FindClose(search_handle);
    }
    //return the search folder full path:
    return strFolderName;
}

//use it:
string File[]={"x86_64-7.2.0-win32-seh-rt_v5-rev1","mingw64"};
    string FileName1=FindDirectory(File);
    MessageBox(NULL,FileName1.c_str(),"hey", MB_OK);

these code works, but sometimes can get 2 or more minutes... is there another faster way?

cambalinho 142 Practically a Posting Shark

heres the entire class:

class image
{
private:
    ULONG_PTR m_gdiplusToken;
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    HDC hdcimage=CreateCompatibleDC(NULL);
    HGDIOBJ obj=NULL;
    HBITMAP btBitmap=NULL;
    Image *img;
    bool isimgused=false;
    bool isGDIPLUSIniciated=false;
    int imageheight=0;
    int imageweight=0;
    int framecount=0;
    int intSelectFrame=0;
    int framedelay=0;
    string strfilename="";
    Gdiplus::Color clrBackColor=Gdiplus::Color::Transparent;
    HDC hdcwindow;
    bool blnTransparent=true;

    void readimagefile(string filename)
    {
        if (isimgused==true)
            delete img;
        strfilename=filename;
        if(toupper(filename[filename.size()-3])=='C' && toupper(filename[filename.size()-2])=='U' && toupper(filename[filename.size()-1])=='R')
        {
            isimgused=false;
            //create the transparent icon handle
            HCURSOR hicon = (HCURSOR)LoadImage(NULL, filename.c_str(), IMAGE_CURSOR, imageweight, imageheight, LR_LOADFROMFILE|LR_SHARED|LR_DEFAULTSIZE|LR_LOADTRANSPARENT);
            ICONINFO ii;
            BOOL fResult = GetIconInfo(hicon, &ii);
            if (fResult)
            {
                BITMAP bm;
                fResult = GetObject(ii.hbmMask, sizeof(bm), &bm) == sizeof(bm);
                if (fResult)
                {
                    imageweight= bm.bmWidth;
                    imageheight= ii.hbmColor ? bm.bmHeight : bm.bmHeight / 2;
                }
                if (ii.hbmMask) DeleteObject(ii.hbmMask);
                if (ii.hbmColor) DeleteObject(ii.hbmColor);
            }
            btBitmap=CreateBitmap(imageweight,imageheight,1,32,NULL);//create the bitmap with icon size
            obj = SelectObject(hdcimage, btBitmap);//add the bitmap to memory DC
            DrawIconEx(hdcimage,0,0,hicon,imageweight,imageheight,0,0,DI_NORMAL);//draw the icon to DC with right size
            //seems the DrawIcon(), always, draw it with 32X32 size
            framecount=1;
            DestroyCursor(hicon);
        }
        else
        {
            isimgused=true;
            Gdiplus::Image img2(towstring(filename).c_str());
            imageweight=img2.GetWidth();
            imageheight=img2.GetHeight();
            btBitmap=CreateBitmap(imageweight,imageheight,1,32,NULL);
            obj = SelectObject(hdcimage, btBitmap);
            Gdiplus::Graphics graphics(hdcimage);
            graphics.DrawImage(&img2, 0,0,imageweight,imageheight);

            UINT count = 0;
            count = img2.GetFrameDimensionsCount();
            GUID* pDimensionIDs = (GUID*)malloc(sizeof(GUID)*count);
            img2.GetFrameDimensionsList(pDimensionIDs, count);
            framecount=img2.GetFrameCount(&pDimensionIDs[0]);
            framedelay =img2.GetPropertyItemSize(PropertyTagFrameDelay);
            img=new Image(towstring(filename).c_str());
            isimgused=true;
            free(pDimensionIDs);
        }
    }

    HICON HICONFromHBITMAP(HBITMAP bitmap)
    {
        BITMAP bmp;
        GetObject(bitmap, sizeof(BITMAP), &bmp);
        HBITMAP hbmMask = CreateCompatibleBitmap(GetDC(NULL), bmp.bmWidth, bmp.bmHeight);

        ICONINFO ii = {0};
        ii.fIcon    = TRUE;
        ii.hbmColor = bitmap;
        ii.hbmMask  = hbmMask;

        HICON hIcon = CreateIconIndirect(&ii);
        DeleteObject(hbmMask);

        return hIcon;
    }

public:

    image()
    {
        if (isimgused==true)
            delete img;
        isimgused=false;
        if(isGDIPLUSIniciated==false)
        {
            Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
            isGDIPLUSIniciated=true;
        }

        btBitmap=CreateCompatibleBitmap(hdcimage,1,1);
        obj = SelectObject(hdcimage, btBitmap);
        imageheight=1;
        imageweight=1;
    }

    image(HDC hdcWindow)
    {
        if (isimgused==true) …
cambalinho 142 Practically a Posting Shark

how avoid memory leaks?
from here: http://www.winprog.org/tutorial/bitmaps.html
i learned:

GetDC() - ReleaseDC()
BeginPaint() - EndPaint()
CreateCompatibleDC() - DeleteDC() 

i must get the old selected object. select it when isn't needed and then delete it.
so seen these constructor and desctructor:

image(const int width, const int height)
    {
        if (isimgused==true)
            delete img;
        isimgused=false;
        if(isGDIPLUSIniciated==false)
        {
            Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
            isGDIPLUSIniciated=true;
        }
        SelectObject(hdcimage, obj);
        DeleteObject(btBitmap);
        DeleteObject(obj);
        DeleteDC(hdcimage);
        hdcimage = CreateCompatibleDC(NULL);
        btBitmap = CreateBitmap(width,height,1,32,NULL);
        obj = SelectObject(hdcimage, btBitmap);
        framecount=1;
        imageheight=height;
        imageweight=width;
    }

~image()
    {
        if(isimgused==true)
            delete img;
        if(isGDIPLUSIniciated==true)
            Gdiplus::GdiplusShutdown(m_gdiplusToken);
        SelectObject(hdcimage, obj);
        DeleteObject(btBitmap);
        DeleteDC(hdcimage);
    }

and these function:

void DrawHICONtoHDC(HDC hdc, HICON hIcon, int PosX=0, int PosY=0)
{
    BITMAP BMInf;
    ICONINFO    csII;
    GetIconInfo(hIcon, &csII);
    GetObject(csII.hbmColor, sizeof(BMInf), &BMInf);
    HDC MemDCExercising = CreateCompatibleDC(hdc);
    HBITMAP hBitmap=CreateBitmap(BMInf.bmWidth ,BMInf.bmHeight,1,32,0);
    HBITMAP oldbitmap =(HBITMAP) SelectObject(MemDCExercising, hBitmap);
    DrawIcon(MemDCExercising,0,0,hIcon);
    TransparentBlt(hdc, PosX, PosY, BMInf.bmWidth , BMInf.bmHeight, MemDCExercising, 0, 0,BMInf.bmWidth , BMInf.bmHeight,GetPixel(MemDCExercising,BMInf.bmWidth-1,BMInf.bmHeight-1) );
    SelectObject(MemDCExercising,oldbitmap);
    DeleteDC(MemDCExercising);
    DeleteObject(oldbitmap);
    ::DeleteObject(csII.hbmColor);
    ::DeleteObject(csII.hbmMask);
    DestroyIcon(hIcon);
    DeleteObject(hBitmap);
}

what i'm doing wrong?
from a windows tool: the HDC, HBITMAP, HPEN, HBRUSH continue been created, instead delete the old one when isn't needed

cambalinho 142 Practically a Posting Shark

i know move the mouse for where i want. but how can send a click message to another program?

cambalinho 142 Practically a Posting Shark

thanks for correct me that. now i know that i can change my BL-5F to BL-6F without a problem ;)
because i use a diferent theme(needs more batery) and i use 3G mobile network(needs more batery too), and the original batery don't works 24h of capacity :(
thanks for all.. thanks

rubberman commented: Remember, when it comes to capacity (Amp Hours), more is better! +12
cambalinho 142 Practically a Posting Shark

problem resolved:
1 - we must get the hdc and the string(with DT_CALRECT flag) rectangle:

RECT rect, textrect;
GetClientRect(hwnd,&rect);
DrawText(hdc,"hello world\nhi\thello mother\nhello my dog",-1, &textrect, DT_CALCRECT);

now we change the top of hdc rectangle(rect):

rect.top=rect.bottom/2-textrect.bottom/2;// remember the rect is, always, less than textrect, or we can get negative values ;)

now we can show the text in vertical center:

DrawText(hdc,"hello world\nhi\thello mother\nhello my dog",-1, &rect, DT_CENTER | DT_EXPANDTABS);

thanks for all

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

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

having test more and i found it.
when we create a window, we must choose what we need. theres some standard const's too ;)
when we need change it: we use the SetWindowLong() function very cool.
readers don't forget use GWL_STYLE for normal styles and GWL_EX_STYLE for EX styles;)

cambalinho 142 Practically a Posting Shark

now i have a new version of the blink text:

//blinktext.h
#include <windows.h>
#include <process.h>

#include <string>
#include <iostream>
using namespace std;

//ForeColor
const int ForeColorBlack        = 0;
const int ForeColorBlue         = FOREGROUND_BLUE;
const int ForeColorGreen        = FOREGROUND_GREEN;
const int ForeColorCyan         = FOREGROUND_BLUE | FOREGROUND_GREEN;
const int ForeColorRed          = FOREGROUND_RED;
const int ForeColorMagenta      = FOREGROUND_BLUE | FOREGROUND_RED;
const int ForeColorBrown        = FOREGROUND_GREEN | FOREGROUND_RED;
const int ForeColorLightGray    = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
const int ForeColorDarkGray     = FOREGROUND_INTENSITY;
const int ForeColorLightBlue    = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
const int ForeColorLightGreen   = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
const int ForeColorLightCyan    = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
const int ForeColorLightRed     = FOREGROUND_RED |  FOREGROUND_INTENSITY;
const int ForeColorLightMagenta = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
const int ForeColorYellow       = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
const int ForeColorWhite        = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;

//BackColor
const int BackColorBlack        = 0;
const int BackColorBlue         = BACKGROUND_BLUE;
const int BackColorGreen        = BACKGROUND_GREEN;
const int BackColorCyan         = BACKGROUND_BLUE | BACKGROUND_GREEN;
const int BackColorRed          = BACKGROUND_RED;
const int BackColorMagenta      = BACKGROUND_BLUE | BACKGROUND_RED;
const int BackColorBrown        = BACKGROUND_GREEN | BACKGROUND_RED;
const int BackColorLightGray    = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED;
const int BackColorDarkGray     = BACKGROUND_INTENSITY;
const int BackColorLightBlue    = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
const int BackColorLightGreen   = BACKGROUND_GREEN | BACKGROUND_INTENSITY;
const int BackColorLightCyan    = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY;
const int BackColorLightRed     = BACKGROUND_RED |  BACKGROUND_INTENSITY;
const int BackColorLightMagenta = BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY;
const int BackColorYellow       = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
const int BackColorWhite        = BACKGROUND_BLUE | BACKGROUND_GREEN | …
cambalinho 142 Practically a Posting Shark

sorry about that. or it's compiler mingw bbug, i don't know...
see my new code with colors working:

//blinktext.h

#define WINVER 0x0501
#define _WIN32_WINNT WINVER
#include <windows.h>
#include <process.h>

#include <string>
#include <iostream>
using namespace std;

struct Blink
{
    string Text;
    int x;
    int y;
    COLORREF TextColor;
    COLORREF BackColor;
};

unsigned __stdcall BlinkLoop(void *params)
{
    Blink *p = static_cast<Blink *>(params);

    int tlen = (int)p->Text.length();

    HDC hDC = GetDC(GetConsoleWindow());

    HBRUSH hb = CreateSolidBrush(p->BackColor);

    LOGFONT lf;

    GetObject(GetStockObject(OEM_FIXED_FONT), sizeof(LOGFONT), &lf);
    lf.lfWeight = FW_REGULAR;

    HFONT hf = CreateFont(lf.lfHeight, lf.lfWidth,
            lf.lfEscapement, lf.lfOrientation, lf.lfWeight,
            lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet,
            lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality,
            lf.lfPitchAndFamily, lf.lfFaceName);

    SelectObject(hDC, (HGDIOBJ)(HFONT)hf);
    SetTextColor(hDC, p->TextColor);
    SetBkMode(hDC, TRANSPARENT);

    TEXTMETRIC tm;

    GetTextMetrics(hDC, &tm);

    RECT rt;

    rt.left = p->x * tm.tmAveCharWidth;
    rt.top = p->y * tm.tmHeight;
    rt.right = rt.left + tlen * tm.tmAveCharWidth;
    rt.bottom = rt.top + tm.tmHeight;

    while (true)
    {
        TextOut(hDC, rt.left, rt.top, p->Text.c_str(), tlen+1);//readers if the text isn't showed take of the '+1'
                Sleep(500);
        FillRect(hDC, &rt, hb);
                Sleep(500);
    }
    return 0;
}

void TextBlink(const string& Text, int x, int y, COLORREF TextColor, COLORREF BackColor)
{
    Blink *b = new Blink;
    b->Text = Text;
    b->BackColor = BackColor;
    b->TextColor = TextColor;
    b->x=x;
    b->y =y;

    _beginthreadex(NULL, 0, BlinkLoop, b, 0, NULL);
}

//main.cpp

#include <iostream>
#include "blinktext.h"


using namespace std;

int main()
{
    TextBlink("This text blinks ok", 0, 0, RGB(0, 255, 0), RGB(0, 0, 0));
    TextBlink("and so does this text", 4, 5, RGB(255, 255, 255), RGB(0, 0, 0));
    TextBlink("this text also blinks ok", 6, 8, RGB(255, 255, 255), RGB(0, 0, 0));


    cin.get();
    return 0;
}
kal_crazy commented: This does blink +2
cambalinho 142 Practically a Posting Shark

i have code for write on console and change the text color and backcolor and clear screen(and much more) inside of a nice class console.
these function change the text color and back color:

    void SetColorAndBackground(int ForgC, int BackC=0)
    {
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), ForgC|(BackC<<4) );
    }

but is there any way for blink the text?

cambalinho 142 Practically a Posting Shark

thanks.... thanks for all. thanks to all

cambalinho 142 Practically a Posting Shark

sorry, i think, by forum rules, we can't. but take these free(realy free):
C++ tutorial: http://www.tutorialspoint.com/cplusplus/cpp_tutorial.pdf
C tutorial: http://www.tutorialspoint.com/cprogramming/cprogramming_tutorial.pdf

they are totaly free. but, in forums, i think we can't share ebooks. but read these nice tutorials and the links that i posted.
good learning