Quantcast
Viewing all 583 articles
Browse latest View live

Can't set text in Edit Box of ComboBox

Hi,

I have a Combo Box and when the user selects an item from the dropdown, I want to edit it before it shows up in the Edit Box. So I capture the CBN_SELCHANGE message and I read the user's selection, edit it a bit, and then set it in the Edit Box using ComboBox_SetText(hwndCtl, lpsz) which is equivalent to SetWindowText((hwndCtl), (lpsz)). After I set it I read it back and it is set. However, it does not show up in the Edit Box to the user. The contents of the Edit Box is the dropdown item the user selected and not what I set. I don't understand what I'm doing wrong.

So basically, I'm doing the following:

case CBN_SELCHANGE:

{
/* Get index of current selection and the text of that selection. */
TCHAR buffer[200];
int index = SendMessage(m_hRecipients, CB_GETCURSEL, (WORD)0, 0L);
SendMessage(m_hRecipients, CB_GETLBTEXT, (WPARAM)index, (LPARAM)buffer);

//Get current contents of Edit Box
int nLngth = SendMessage(m_hRecipients, WM_GETTEXTLENGTH, NULL, NULL);
csRecipients = (TCHAR *)CoTaskMemAlloc(nLngth);

SendMessage(m_hRecipients, WM_GETTEXT, nLngth+1, (LRESULT)csRecipients);

// concat new selection to contents of Edit Box (current rescipient list)
if (nLngth > 0) tcscat(csRecipients, L",");
_tcscat(csRecipients, buffer);

// set the new contents of the Edit Box
ComboBox_SetText(m_hRecipients, (LPCWSTR)csRecipients);

return TRUE;
}

Can anyone suggest what I'm doing wrong that the Edit Box doesn't persist the contents I set?

Thank you very much,
Jitendra

[RESOLVED] what's wrong with 'cout' with strings?:(

see these class:
Code:

#include <iostream>
#include <Windows.h>
#define MY_BUFSIZE 1024
using namespace std;




class Console
{
char pszOldWindowTitle[MY_BUFSIZE];


        public:
string Title() //the problem seems to be here, but no erro message here
        {               
                GetWindowText(GetForegroundWindow(), pszOldWindowTitle, GetWindowTextLength(GetForegroundWindow()) + 1);
                return string(pszOldWindowTitle);
        }
       
        void Title(string title)  //these procedure works fine
        {               
                SetConsoleTitle(title.c_str());
        }
};

(sorry the indention, but i can't use 'TAB' key:()
and heres how i use it:

Code:

#include "stdafx.h"
#include "Console.h"
#include <iostream>
#include <conio.h>


int _tmain(int argc, _TCHAR* argv[])
{
        Console a;
    string b =string(a.Title());


    cout << "Title: " << b << endl; //i get 1 problem in second '<<'


    Sleep(5000);


    a.Title("Hello World");


    getch();


    return 0;
}




error message:

1 - "error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)";

2 - " IntelliSense: no operator "<<" matches these operands".

what is wrong with cout???? isn't the 1st time that i get these type of error, but i continue without understand why:(
can anyone explain to me?

[RESOLVED] about console size

the console have 2 types of size, right?
i belive that is the window size and the container size. the window size i can do it, but how can i change the container(i think that you call it buffer or something) size?

[RESOLVED] the hidecaret() function isn't ok?

what i need for hide the caret?
Code:

bool GetCaretVisible()
        {
                return blCaretVisible;
        }
void SetCaretVisible(bool Visible)       
{
                if (Visible==true)
                {
                        ShowCaret(hwnd());
                }
                else
                {
                        HideCaret( hwnd());
                }
        }
        __declspec ( property ( put = SetCaretVisible, get = GetCaretVisible ) ) bool CaretVisible ;

the caret isn't hided, i test the GetLastError() and gives me 0(zero). so what i need for hide the caret?
(more 1 property for my class;))

[RESOLVED] can anyone tell me all colors const for SetConsoleTextAttribute() function?

i have these nice function for change the textcolor\backcolor:

Code:

void SetColorAndBackground(int ForgC, int BackC){
    WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
    return;
}

but can anyone tell me the colors const and and how can i blink?

[RESOLVED] why multithread class don't accept the precedure name?:(

heres my Multihtread class:
Code:

class MultiThread{
        private:               
                bool blnDestroyed;
                HANDLE Handle_Of_Thread_1;
                typedef void (*MyThreadProc)();
                MyThreadProc ThreadProcedure;
                static DWORD WINAPI StaticThreadProc(LPVOID param)
                {
                        static_cast<MultiThread*>(param)->MultithreadProcedure();
                        return 0;
                }


                void  MultithreadProcedure()
                {
                        for (;;)
                        {
                                if (blnDestroyed==true) break;                       
                                ThreadProcedure();
                        }
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                }


        public:
                int Start(MyThreadProc ThreadProc)
                {
                        ThreadProcedure = ThreadProc;
                        Handle_Of_Thread_1=0;
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                        blnDestroyed=false;
                        HANDLE hMyThread;
                        hMyThread = CreateThread(NULL, 0, StaticThreadProc, this, 0, NULL);
                        return 0;
                }


                int Stop()
                {
                        blnDestroyed=true;                       
                        return 0;
                }


                MultiThread::~MultiThread() //for stop if the process isn't stoped before be destroyed
                {
                        Stop();
                }
};

heres how i use it:
Code:

#include "stdafx.h"#include "Console.h"
#include "Thread.h"


Console a;


int  show()
{
        for(;;)
        {
                cout << "hi";
                Sleep(1000);
                a.Clear();
        }       
        return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
       
        MultiThread b;
        b.Start(show());         
    a.Read();       
    return 0;
}

error message:
1 - "error C2664: 'MultiThread::Start' : cannot convert parameter 1 from 'int' to 'MultiThread::MyThreadProc'";
2 - " IntelliSense: argument of type "int" is incompatible with parameter of type "MultiThread::MyThreadProc"".
what i'm wrong?

[RESOLVED] invalid parameter?

i'm using these code for get and set the caret positions:
Code:

CONSOLE_SCREEN_BUFFER_INFOEX bufferInfo;
                GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE),&bufferInfo);

with GetLastError(), i recive the "ERROR_INVALID_PARAMETER"...why????
i belive that the handle is correct and the 2nd parameter is correctly used. so what is the problem?
the SetConsoleScreenBufferInfoEx() funtion gives me the same error:(
(yesterday i learned very... now i can detect the errors hehehe)

[RESOLVED] clear the console


how use WriteConsoleOutputAttribute() function?

i'm trying use the WriteConsoleOutputAttribute() function for create the blink effect, but seems not working:(
seems that i'm confuse the the parameters types:(
Code:

void BlinkText(char *Text, COORD TextPos, int BackColor, int Forecolor)        {               
                WriteConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE),Forecolor|BackColor<<4,strlen(Text),TextPos,Text);
        }

can anyone advice me?

Keyboard event handling on List view

Hi all,
In my win 32 application,I have adilaog box and inside that one list view control to display some records.I want to use Find dialogue box for this List view.
1.How can i identify Cntrl+f event under LVN_KEYDOWN
2.I registered the FINDMESSAGESTRING in Win main function.and written the handler for FR_FINDNXT on default case of DialogProc.But control is not going to this handler.
Code:

//Dialog procedure
extern UINT uFindReplaceMsg; // message identifier FINDMSGSTRING decared and registerd in main file
HWND HdlgFindOrReplce = NULL;    // handle to Find dialog box

LRESULT CALLBACK DlgtProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{

 switch (uMsg)
{
case WM_INITDIALOG://setting the items & subitem values
break;
case WM_NOTIFY:
  switch(LOWORD(wParam))
 {
    case IDC_LISTVIEW:
      switch(((LPNMHDR)lParam)->code)
    {
        case LVN_KEYDOWN:
      //wat condition i have to write for Cntrl+F??
        //creating the find dialog box
          break;
      }
    break;
 }
break;
default:
  {
      LPFINDREPLACE lpfr;
      if ( uMsg == uFindReplaceMsg)
                {
                        // Get pointer to FINDREPLACE structure from lParam.
                        lpfr = (LPFINDREPLACE)lParam;
                        // If the FR_DIALOGTERM flag is set,
                        // invalidate the handle identifying the dialog box.

                        if (lpfr->Flags & FR_DIALOGTERM)
                        {
                                HdlgFindOrReplce = NULL;
                                return 0;
                        }

                        // If the FR_FINDNEXT flag is set,
                        // call the application-defined search routine
                        // to search for the requested string.
                        if ((lpfr->Flags & FR_FINDNEXT))
                        {//Handler of find next
                                }
  }
}               
}

how call a procedure, like a new thread, with parameters?

heres my timer class(isn't a good thing, but works lol):
Code:

#include <Windows.h>

//for create a timer
class Timer
{
        private:
                int MilliSecondsTimer;
        private:
                bool blnDestroyed;
        private:
                HANDLE Handle_Of_Thread_1;
                typedef void (*MyTimerProc)();
                MyTimerProc TimerProcedure;
                static DWORD WINAPI StaticThreadProc(LPVOID param)
                {
                        static_cast<Timer*>(param)->MultithreadProcedure();
                        return 0;
                }
        public:
                int SetMilliSeconds(int MilliSeconds)
                {
                        MilliSecondsTimer = MilliSeconds;
                        return 0;
                }
        public:
                int GetMilliSeconds()
                {
                        return (MilliSecondsTimer);
                }
        private: void  MultithreadProcedure()
                {
                        for (;;)
                        {
                                if (blnDestroyed==true) break;
                                Sleep(MilliSecondsTimer);
                                TimerProcedure();
                        }
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                }
        public:
                int Start(MyTimerProc TimerProc(...))
                {
                        TimerProcedure = TimerProc();
                        Handle_Of_Thread_1=0;
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                        blnDestroyed=false;
                        HANDLE hMyThread;
                        hMyThread = CreateThread(NULL, 0, StaticThreadProc, this, 0, NULL);
                        return 0;
                }
        public: int Stop()
                {
                        blnDestroyed=true;                       
                        return 0;
                }
                ~Timer()
                {
                        Stop();
                }
};

imagine that the sub have some arguments, how can use them, when i call the sub?

see these sample:

Code:

Timer c;        c.SetMilliSeconds(100);
        c.Start( SetTextXY(10,10,"hello",100,500));

error message:
"IntelliSense: argument of type "void" is incompatible with parameter of type "Timer::MyTimerProc (*)(...)""
any advice?

Implementation of Tab key on list view

Hi all,
I have a list view created using resource editor,I set Extended style such as LVS_EX_GRIDLINES & LVS_EX_FULLROWSELECT,So my List view looking like a spread sheet.Editing of cell done by Double clicking event,Now I want to add Tab feature(Switching Focus from one cell to next.)Is there any winAPI is there for Tab feature.I tryed to capture VK_TAB under LVN_KEYDOWN,But i am not reciving any notification for that event

win32 API corresponding to GetSubItemRect

Please tell me Win32 API corresponding to CListCtrl::GetSubItemRect()

[RESOLVED] how call a procedure, like a new thread, with parameters?

heres my timer class(isn't a good thing, but works lol):
Code:

#include <Windows.h>

//for create a timer
class Timer
{
        private:
                int MilliSecondsTimer;
        private:
                bool blnDestroyed;
        private:
                HANDLE Handle_Of_Thread_1;
                typedef void (*MyTimerProc)();
                MyTimerProc TimerProcedure;
                static DWORD WINAPI StaticThreadProc(LPVOID param)
                {
                        static_cast<Timer*>(param)->MultithreadProcedure();
                        return 0;
                }
        public:
                int SetMilliSeconds(int MilliSeconds)
                {
                        MilliSecondsTimer = MilliSeconds;
                        return 0;
                }
        public:
                int GetMilliSeconds()
                {
                        return (MilliSecondsTimer);
                }
        private: void  MultithreadProcedure()
                {
                        for (;;)
                        {
                                if (blnDestroyed==true) break;
                                Sleep(MilliSecondsTimer);
                                TimerProcedure();
                        }
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                }
        public:
                int Start(MyTimerProc TimerProc(...))
                {
                        TimerProcedure = TimerProc();
                        Handle_Of_Thread_1=0;
                        CloseHandle(Handle_Of_Thread_1);
                        TerminateThread( Handle_Of_Thread_1,1);
                        blnDestroyed=false;
                        HANDLE hMyThread;
                        hMyThread = CreateThread(NULL, 0, StaticThreadProc, this, 0, NULL);
                        return 0;
                }
        public: int Stop()
                {
                        blnDestroyed=true;                       
                        return 0;
                }
                ~Timer()
                {
                        Stop();
                }
};

imagine that the sub have some arguments, how can use them, when i call the sub?

see these sample:

Code:

Timer c;        c.SetMilliSeconds(100);
        c.Start( SetTextXY(10,10,"hello",100,500));

error message:
"IntelliSense: argument of type "void" is incompatible with parameter of type "Timer::MyTimerProc (*)(...)""
any advice?

Screen resolution problem

Hi,
In my win32 application,i am drawing some boxes on the screen,dimension of this rectangular boxes iam deciding based on the value getting through GetClientRect().But if am running application on different pC(Different monitor size)my boxes with different size how to make it general for all PC

Debug & release mode

One of my win32 application working fine in debug mode.but malfunctioning in release mode.Can i do debug operation on release mode?I tryed to debug in release mode,But valuse showing is not correct.How to solve this problem?

Keeping Dialog Button Selected

I am writing a program in Visual Studios 2012 Express edition I created a Dialog Box using ResEdit that looks like this

Image may be NSFW.
Clik here to view.
Name:  dialog.png
Views: 0
Size:  28.1 KB





I want to make it so when I select the A Button button it stays selected when im changing the value in the repeat and delay editboxes I only want it to deselect it when I click On another button like the B Button button.

Is there a way to make this Dialog Boxes buttons group buttons if not how do I accomplish what im trying to do?
Attached Images
Image may be NSFW.
Clik here to view.
 

Selection of full row via program

I am doing a win32 application using List view control,I used extended style LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT.My application demands for force selection of row(ie,Searching for an item,if it found select that item via program)I tryed with both LVM_SETITEMSTATEas well as ListView_SetItemState,But iam not getting as selected
First code using macro
Code:

itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
MessageBox()//Item already exist
ListView_SetItemState(hWnd, itemNo, LVIS_SELECTED | LVIS_FOCUSED,
0x000f); //fails

using LVM_SETITEMSTATE

Code:

itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
MessageBox()//Item already exist
lvItem.iItem=itemNo;
lvItem.mask=LVIF_STATE;
lvItem.state=LVIS_SELECTED;
lvItem.stateMask=0x00f;
SendMessage(hWnd,LVM_SETITEMSTATE,itemNo,(LPARAM)&lvItem);

Issue with DirectDraw switching from 16 to 32 Bpp

Hello,

It's my first post here and i thanks every people for reading or taking time to my post !

I'm processing to a source's refactoring of one old application before Recoding from scratch and testing a lot of things. I will use Diretct3D but for now it's Directdraw.

Is it possible to Convert surface from 16 BPP to 32 BPP before display on front screen. If yes, does it cost a lot of CPU/RAM ?

Or

Should i convert in every sprite's functions and change pitch, colors, pixels and other parameters ?

English isn't my first language so I hope that you will understand !

Thanks !

Questions Create Databases and Applications

Hi
I am working C++ Builder X2 and i want to ask your opinion wich is the best way to create simple applications

For example is better to use Access or Sql Server and also wich is the best components to connect databases with application.
Viewing all 583 articles
Browse latest View live