Posted May 9, 201015 yr Hello Guys,I was looking for a vertical text scroll engine or lib or simple sample code like u see in the about box of keygen or nfo viewer. I found diablo2oo2's scroll text lib, but it works for text horizontally. I tried downloaded some sample codes of keygen, but they include all extra things and the code is too complex to look at to figure out just how it making the text scroll vertical moving bottom-to-top n top-to-button. Can any one just put a small easy to understand sample code or hints without using any bitmap or effects. Juts simply a dialog box n text scrolling..Thanks in advance...
May 10, 201015 yr // Setup scroller int nLines = 0; LPSTR lpszLine = lpszAboutText; while(*lpszLine){ if(*lpszLine == '\n') nLines++; lpszLine++; } SIZE szAboutText; HDC hdc = GetDC(hWnd); hdcText = CreateCompatibleDC(hdc); ndcText = SaveDC(hdcText); HFONT hfAbout = CreateFontIndirectA(&lfVerdana); SelectObject(hdcText, hfAbout); GetTextExtentPoint32A(hdcText, lpszAboutText, strlen(lpszAboutText), &szAboutText); CopyRect(&rcText, &rcClient); rcText.bottom += (szAboutText.cy * nLines); hbmText = CreateCompatibleBitmap(hdc, rcText.right, rcText.bottom); SelectObject(hdcText, hbmText); ReleaseDC(hWnd, hdc); SetBkMode(hdcText, TRANSPARENT); SetTextColor(hdcText, RGB(255, 255, 255)); rcText.top += rcClient.bottom; DrawTextA(hdcText, lpszAboutText, strlen(lpszAboutText), &rcText, DT_CENTER); DeleteObject(hfAbout); nOffset = 0; nOffsetMax = rcText.bottom; SetTimer(hWnd, 1, 60, NULL);Cheers, Edited May 10, 201015 yr by SSlEvIN
May 11, 201015 yr Author Please speak any more suggestions if anyone still have to say on this, though I didn't got the time to try this code yet.. I would like to know more on this if any. Will ask here for improvements later after trying it Thanx Edited May 11, 201015 yr by Dragon Warrior
May 11, 201015 yr .....................................................................#pragma comment(lib, "msimg32.lib")#pragma comment(lib, "comctl32.lib")#pragma comment(lib, "winmm.lib")#pragma comment(lib, "gdiplus.lib")#include <windows.h>#include <commctrl.h>#include <olectl.h>#include <ole2.h>#include"resource.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <time.h>#include <Winuser.h>#include <gdiplus.h>..........................................................................................................................................LOGFONTA lfVerdana = { -11, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 34, "Courier New" };LPSTR lpszAboutText ="Some Text Here\n\n""Some Text Here \n""Some Text Here""\nSome Text Here\n\n""\nSome Text Here\n""-----------\n""Some Text Here\n""Some Text Here\n""Some Text Here\n\n""Some Text Here\n\n""Some Text Here\n""Some Text Here\n\n\n""Some Text Here\n\n";..................................................................................................BOOL CALLBACK AboutProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ static HBITMAP hbmText; static HDC hdcText; static int ndcText, nOffset, nOffsetMax; switch(uMsg) { case WM_INITDIALOG: { SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_TOPMOST); hUserDll = LoadLibraryA("USER32.dll"); RECT rcClient, rcText; GetClientRect(hWnd, &rcClient); } // Setup scroller int nLines = 0; LPSTR lpszLine = lpszAboutText; while(*lpszLine){ if(*lpszLine == '\n') nLines++; lpszLine++; } SIZE szAboutText; HDC hdc = GetDC(hWnd); hdcText = CreateCompatibleDC(hdc); ndcText = SaveDC(hdcText); HFONT hfAbout = CreateFontIndirectA(&lfVerdana); SelectObject(hdcText, hfAbout); GetTextExtentPoint32A(hdcText, lpszAboutText, strlen(lpszAboutText), &szAboutText); CopyRect(&rcText, &rcClient); rcText.bottom += (szAboutText.cy * nLines); hbmText = CreateCompatibleBitmap(hdc, rcText.right, rcText.bottom); SelectObject(hdcText, hbmText); ReleaseDC(hWnd, hdc); SetBkMode(hdcText, TRANSPARENT); SetTextColor(hdcText, RGB(255, 255, 255); <-------- White text rcText.top += rcClient.bottom; DrawTextA(hdcText, lpszAboutText, strlen(lpszAboutText), &rcText, DT_CENTER); DeleteObject(hfAbout); nOffset = 0; nOffsetMax = rcText.bottom; SetTimer(hWnd, 1, 60, NULL); } return TRUE; case WM_TIMER: { RECT rcClient; GetClientRect(hWnd, &rcClient); } if(nOffset < nOffsetMax) nOffset += 1; else nOffset = 0; InvalidateRect(hWnd, NULL, FALSE); } return 0; case WM_LBUTTONDOWN: SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); return TRUE; case WM_RBUTTONUP: SendMessage(hWnd, WM_CLOSE, 0, 0); return TRUE; case WM_CLOSE: KillTimer(hWnd, 1); RestoreDC(hdcText, ndcText); DeleteObject(hbmText); DeleteDC(hdcText); EndDialog(hWnd, 0); return TRUE; } return FALSE; Ok, here is a bit "purified" code, which of course is not mine, but I thought it was needless to say, Mate ... my coding skills sux ... Cheers, SS.
May 12, 201015 yr Seems you got carried away a little with the purification there I can only agree, but sorry, cant show all ... thats why I put purification in quotation marks ...
May 13, 201015 yr Author I m running XpSp3 and using VC 6.0 . How do i make use of gdiplus. I tried downloading the sdk, it contains a dll named gdiplus.dll. Someone said that xp already comes with gdiplus...<br /><br />but my program just donno where to find include <gdiplus.h>. How do i setup and configure gdiplus for VC 6 ?(Sorry, if my question looks silly, I m just new to gdi+) Edited May 13, 201015 yr by Dragon Warrior
May 13, 201015 yr My first guess would be that VC6 doesn't have the gdiplus headers at all. It's from before 2000, mind you and GDI Plus came with XP or something. You might wanna switch to a more recent compiler (VS 2010 just got released)
July 7, 201213 yr @SSlEVIN : Your code is not working.Here is what I have done, actually nothing just WinMain()#pragma comment(lib, "msimg32.lib")#pragma comment(lib, "comctl32.lib")#pragma comment(lib, "winmm.lib")#pragma comment(lib, "gdiplus.lib")#include <windows.h>#include <commctrl.h>#include <olectl.h>#include <ole2.h>#include"resource.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <time.h>#include <Winuser.h>#include <gdiplus.h>HMODULE hUserDll;LOGFONTA lfVerdana = { -11, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 34, "Courier New" };LPSTR lpszAboutText ="Some Text Here\n\n""Some Text Here \n""Some Text Here""\nSome Text Here\n\n""\nSome Text Here\n""-----------\n""Some Text Here\n""Some Text Here\n""Some Text Here\n\n""Some Text Here\n\n""Some Text Here\n""Some Text Here\n\n\n""Some Text Here\n\n";BOOL CALLBACK AboutProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ static HBITMAP hbmText; static HDC hdcText; static int ndcText, nOffset, nOffsetMax; switch(uMsg) { case WM_INITDIALOG: { SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_TOPMOST); hUserDll = LoadLibraryA("USER32.dll"); RECT rcClient, rcText; GetClientRect(hWnd, &rcClient); // Setup scroller int nLines = 0; LPSTR lpszLine = lpszAboutText; while(*lpszLine) { if(*lpszLine == '\n') nLines++; lpszLine++; } SIZE szAboutText; HDC hdc = GetDC(hWnd); hdcText = CreateCompatibleDC(hdc); ndcText = SaveDC(hdcText); HFONT hfAbout = CreateFontIndirectA(&lfVerdana); SelectObject(hdcText, hfAbout); GetTextExtentPoint32A(hdcText, lpszAboutText, strlen(lpszAboutText), &szAboutText); CopyRect(&rcText, &rcClient); rcText.bottom += (szAboutText.cy * nLines); hbmText = CreateCompatibleBitmap(hdc, rcText.right, rcText.bottom); SelectObject(hdcText, hbmText); ReleaseDC(hWnd, hdc); SetBkMode(hdcText, TRANSPARENT); SetTextColor(hdcText, RGB(0, 0, 255)); // Color of Text rcText.top += rcClient.bottom; DrawTextA(hdcText, lpszAboutText, strlen(lpszAboutText), &rcText, DT_CENTER); DeleteObject(hfAbout); nOffset = 0; nOffsetMax = rcText.bottom; SetTimer(hWnd, 1, 60, NULL); } return true; case WM_TIMER: { RECT rcClient; GetClientRect(hWnd, &rcClient); if(nOffset < nOffsetMax) nOffset += 1; else nOffset = 0; InvalidateRect(hWnd, NULL, FALSE); } return true; case WM_CLOSE: KillTimer(hWnd, 1); RestoreDC(hdcText, ndcText); DeleteObject(hbmText); DeleteDC(hdcText); EndDialog(hWnd, 0); return true; } return false;}int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd){ DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),HWND_DESKTOP,DLGPROC(&AboutProc),NULL);}
July 8, 201213 yr Last reply prior to yours:Posted 13 May 2010More than 2 years since anybody has posted anything in the thread?HR,Ghandi
Create an account or sign in to comment