Click here to Skip to main content
15,123,408 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sieve of Eratosthenes Pin
Kenneth Haugland13-Sep-12 4:33
professionalKenneth Haugland13-Sep-12 4:33 
AnswerRe: Sieve of Eratosthenes Pin
PIEBALDconsult12-Sep-12 15:23
professionalPIEBALDconsult12-Sep-12 15:23 
QuestionSubstitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 5:23
MemberASPnoob12-Sep-12 5:23 
AnswerRe: Substitution of Paths in HyperLinkField with File Names Pin
Pete O'Hanlon12-Sep-12 5:55
mvePete O'Hanlon12-Sep-12 5:55 
GeneralRe: Substitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 10:59
MemberASPnoob12-Sep-12 10:59 
QuestionRetrieve name of Printer using SendMessage Pin
toBeH_S11-Sep-12 23:10
MembertoBeH_S11-Sep-12 23:10 
AnswerRe: Retrieve name of Printer using SendMessage Pin
Rage12-Sep-12 7:40
professionalRage12-Sep-12 7:40 
GeneralRe: Retrieve name of Printer using SendMessage Pin
toBeH_S12-Sep-12 9:33
MembertoBeH_S12-Sep-12 9: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 22:25
professionalRage12-Sep-12 22:25 
GeneralRe: Retrieve name of Printer using SendMessage Pin
toBeH_S16-Sep-12 16:18
MembertoBeH_S16-Sep-12 16:18 
QuestionRandom Permutation Interface Pin
Skippums11-Sep-12 16:58
MemberSkippums11-Sep-12 16:58 
AnswerRe: Random Permutation Interface Pin
Dave Kreskowiak11-Sep-12 18:44
mveDave Kreskowiak11-Sep-12 18:44 
AnswerRe: Random Permutation Interface Pin
BillWoodruff12-Sep-12 1:05
mveBillWoodruff12-Sep-12 1:05 
AnswerRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 1:18
mvePete O'Hanlon12-Sep-12 1:18 
GeneralRe: Random Permutation Interface Pin
Dave Kreskowiak12-Sep-12 3:21
mveDave Kreskowiak12-Sep-12 3:21 
AnswerRe: Random Permutation Interface Pin
BobJanova12-Sep-12 2:17
MemberBobJanova12-Sep-12 2:17 
GeneralRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 2:27
mvePete O'Hanlon12-Sep-12 2:27 
GeneralRe: Random Permutation Interface Pin
Skippums12-Sep-12 7:41
MemberSkippums12-Sep-12 7:41 
AnswerRe: Random Permutation Interface Pin
PIEBALDconsult12-Sep-12 4:07
professionalPIEBALDconsult12-Sep-12 4:07 
AnswerRe: Random Permutation Interface Pin
Skippums12-Sep-12 8:32
MemberSkippums12-Sep-12 8:32 
GeneralRe: Random Permutation Interface Pin
BillWoodruff13-Sep-12 3:37
mveBillWoodruff13-Sep-12 3:37 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 4:23
professionalPIEBALDconsult13-Sep-12 4:23 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 4:27
professionalPIEBALDconsult13-Sep-12 4:27 
GeneralRe: Random Permutation Interface Pin
Skippums13-Sep-12 8:27
MemberSkippums13-Sep-12 8:27 
Questionconvert xdocument to integer Pin
rachel_m11-Sep-12 13:16
Memberrachel_m11-Sep-12 13: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.