Click here to Skip to main content
15,881,831 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
mvePIEBALDconsult12-Sep-12 14:23 
QuestionSubstitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 4:23
ASPnoob12-Sep-12 4:23 
AnswerRe: Substitution of Paths in HyperLinkField with File Names Pin
Pete O'Hanlon12-Sep-12 4:55
mvePete O'Hanlon12-Sep-12 4:55 
GeneralRe: Substitution of Paths in HyperLinkField with File Names Pin
ASPnoob12-Sep-12 9:59
ASPnoob12-Sep-12 9:59 
QuestionRetrieve name of Printer using SendMessage Pin
toBeH_S11-Sep-12 22:10
toBeH_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
toBeH_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
toBeH_S16-Sep-12 15:18 
QuestionRandom Permutation Interface Pin
Skippums11-Sep-12 15:58
Skippums11-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
professionalBillWoodruff12-Sep-12 0:05 
AnswerRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 0:18
mvePete 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
BobJanova12-Sep-12 1:17 
GeneralRe: Random Permutation Interface Pin
Pete O'Hanlon12-Sep-12 1:27
mvePete O'Hanlon12-Sep-12 1:27 
GeneralRe: Random Permutation Interface Pin
Skippums12-Sep-12 6:41
Skippums12-Sep-12 6:41 
AnswerRe: Random Permutation Interface Pin
PIEBALDconsult12-Sep-12 3:07
mvePIEBALDconsult12-Sep-12 3:07 
AnswerRe: Random Permutation Interface Pin
Skippums12-Sep-12 7:32
Skippums12-Sep-12 7:32 
GeneralRe: Random Permutation Interface Pin
BillWoodruff13-Sep-12 2:37
professionalBillWoodruff13-Sep-12 2:37 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 3:23
mvePIEBALDconsult13-Sep-12 3:23 
GeneralRe: Random Permutation Interface Pin
PIEBALDconsult13-Sep-12 3:27
mvePIEBALDconsult13-Sep-12 3:27 
GeneralRe: Random Permutation Interface Pin
Skippums13-Sep-12 7:27
Skippums13-Sep-12 7:27 
Questionconvert xdocument to integer Pin
rachel_m11-Sep-12 12:16
rachel_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.