All pastes #280467 Raw Edit

VoiDeD

public cpp v1 · immutable
·published 2006-12-15 22:51 UTC
rendered paste body
/*  * Winamp Music :: VoiDAPI Test Project * ----------------------------------- * Coded by: VoiDeD * * Uses: - WinAPI (window handles) *       - VoiDAPI * * Time Spent: 20mins of wondering how text arrays work **/#include "voidapi.h"//main windowv_window* wnd;//song title labelv_control* ctrl;//song check threadv_thread* thrd;//winamp handleHWND winamp;void destroy(v_window* wind){ //called when the window is closed	//destroys the window    wind->destroy();}void loop(v_thread* thread, void* data) { //this thread checks song title every 500 milliseconds    while(true) {		//create a text buffer        char text[256];        //get song title        int len = GetWindowText(winamp, text, 256);                for (int x = 0; x < 9; x++) {			//trim " - Winamp" from song title            text[len-x] = 0;        }                //char num        int inc = 0;		        while (text[inc] != '.') //loop till a "." is found			//increase char num            inc++;        //increase twice to compensate for ". "        inc += 2;                //new text buffer        char text_buf[256]; //new text buffer        for (int x = 0; x < len; x++) //create a new song string            text_buf[x] = text[x+inc];                	//set the label text        ctrl->set_text(text_buf);                //sleep for 500 ms        thread->sleep(500);    }}int main(){	//make a new thread    thrd = new v_thread(&loop, NULL);    	//make a new window    wnd = new v_window("WinAMP Music", new v_size(400,55));     //make a new label    ctrl = new v_label(        "NP: <nothing>",        new v_size(400,55),        new v_point(0,0),        wnd->get_hwnd()    );    //register close event    wnd->register_event(WM_CLOSE, &destroy);     //add the label    wnd->control_add(ctrl);         //get winamp handle (v5.2 only?)    winamp = FindWindow("Winamp v1.x", NULL);         //start thread    thrd->start();         //show the window    wnd->show();}