Click here to Skip to main content
15,399,945 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sieve of Eratosthenes Pin
Kenneth Haugland13-Sep-12 3:33
mvaKenneth Haugland13-Sep-12 3:33 
AnswerRe: Sieve of Eratosthenes Pin
PIEBALDconsult12-Sep-12 14:23
professionalPIEBALDconsult12-Sep-12 14:23 
QuestionSubstitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 4:23
MemberASPnoob12-Sep-12 4:23 
AnswerRe: Substitution of Paths in HyperLinkField with File Names Pin
Pete O'Hanlon12-Sep-12 4:55
mvaPete O'Hanlon12-Sep-12 4:55 
GeneralRe: Substitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 9:59
MemberASPnoob12-Sep-12 9:59 
QuestionRetrieve name of Printer using SendMessage Pin
toBeH_S11-Sep-12 22:10
MembertoBeH_S11-Sep-12 22:10 
AnswerRe: Retrieve name of Printer using SendMessage Pin
Rage12-Sep-12 6:40
professionalRage12-Sep-12 6:40 
GeneralRe: Retrieve name of Printer using SendMessage Pin
toBeH_S12-Sep-12 8:33
MembertoBeH_S12-Sep-12 8:33 
Rage wrote:
What is the following code doing:

 

C#
StringBuilder title = new StringBuilder();
 
Int32 sSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32();
 
// If the return is 0, there is no title. 
if (sSize > 0)
{
        sbTitle = new StringBuilder(sSize + 1);
        SendMessage(hwnd,( int)WM_GETTEXT, sbTitle.Capacity, sbTitle);
 
}
return sbTitle.ToString();


1. The above code retrieves the name of the printer chosen from the printer name combobox in printDialog.
hwnd : handle of the printer name combobox in PrintDialog of Acrobat.

1) Firstly, get the length of the printer name.
int sSize=SendMessage((int)hwnd, WM_GETTEXTLENGTH, 0,0),ToInt32();

2) Secondly, memory allocation for the name of the printer.
sbTitle = new StringBuilder( sSize + 1);

3) Finally, retrieve the name of the printer using SendMessage Windows API.
SendMessage(hwnd, (int)WM_GETTEXT, sbTitle.Capacity, sbTitle);

What I want is to retrieve the name of the printer chosen in acrobat printDialog from another application via SendMessage.

2.
Rage wrote:
There could also be a Unicode problem.

Maybe you right.
The original version is as follows:
if ( isWindowUnicode(hwnd)) {
        StringBuilder title = new StringBuilder();

         Int32 sSize = SendMessageW((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32();

       // If the return is 0, there is no title.
       if (sSize > 0)
       {
                  sbTitle = new StringBuilder(sSize + 1);
                  SendMessageW(hwnd,( int)WM_GETTEXT, sbTitle.Capacity, sbTitle);

       }
      return sbTitle.ToString();
}

GeneralRe: Retrieve name of Printer using SendMessage Pin
Rage12-Sep-12 21:25
professionalRage12-Sep-12 21:25 
GeneralRe: Retrieve name of Printer using SendMessage Pin
toBeH_S16-Sep-12 15:18
MembertoBeH_S16-Sep-12 15:18 
QuestionRandom Permutation Interface Pin
Skippums11-Sep-12 15:58
MemberSkippums11-Sep-12 15:58 
AnswerRe: Random Permutation Interface Pin
Dave Kreskowiak11-Sep-12 17:44
mveDave Kreskowiak11-Sep-12 17:44 
AnswerRe: Random Permutation Interface Pin
BillWoodruff12-Sep-12 0:05
mveBillWoodruff12-Sep-12 0:05 
AnswerRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 0:18
mvaPete O'Hanlon12-Sep-12 0:18 
GeneralRe: Random Permutation Interface Pin
Dave Kreskowiak12-Sep-12 2:21
mveDave Kreskowiak12-Sep-12 2:21 
AnswerRe: Random Permutation Interface Pin
BobJanova12-Sep-12 1:17
MemberBobJanova12-Sep-12 1:17 
GeneralRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 1:27
mvaPete O'Hanlon12-Sep-12 1:27 
GeneralRe: Random Permutation Interface Pin
Skippums12-Sep-12 6:41
MemberSkippums12-Sep-12 6:41 
AnswerRe: Random Permutation Interface Pin
PIEBALDconsult12-Sep-12 3:07
professionalPIEBALDconsult12-Sep-12 3:07 
AnswerRe: Random Permutation Interface Pin
Skippums12-Sep-12 7:32
MemberSkippums12-Sep-12 7:32 
GeneralRe: Random Permutation Interface Pin
BillWoodruff13-Sep-12 2:37
mveBillWoodruff13-Sep-12 2:37 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 3:23
professionalPIEBALDconsult13-Sep-12 3:23 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 3:27
professionalPIEBALDconsult13-Sep-12 3:27 
GeneralRe: Random Permutation Interface Pin
Skippums13-Sep-12 7:27
MemberSkippums13-Sep-12 7:27 
Questionconvert xdocument to integer Pin
rachel_m11-Sep-12 12:16
Memberrachel_m11-Sep-12 12:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.