I just cannot maximize a certain window.I'm using ShowWindow,I tried with all the SW_ parameters,and nothing.And yes,I'm 100% the hwnd is the correct one.
↧
Cannot maximize window
↧
Take screenshot of Window while in Taskbar
Is it possible to take a screenshot of a window while it's in the taskbar? If yes,please give me some example code.
↧
↧
Code hangs on using sendmail command of smtp ?
Hi,
I m trying to send a mail via c++ code. I downloaded EASendMail component installer in ma system.
Then using this i wrote a code in vc++. I m sending a mail using a gmail id.I m able to send the mail correctly.
The issue i m facing is that the code hangs for the time it takes to send the mail.when i get a notification tat the mail is sent , den the cursor becomes active.I send the receiver address to the function i m calling.
<code>
using namespace EASendMailObjLib;
using namespace std;
int SendMail(LPTSTR RecieverID)
{
::CoInitialize( NULL );
IMailPtr oSmtp = NULL;
oSmtp.CreateInstance( "EASendMailObj.Mail");
oSmtp->LicenseCode = L"TryIt";
// Set your gmail email address
oSmtp->FromAddr = L"mygmailid@gmail.com";
// Add recipient email address
oSmtp->AddRecipientEx( RecieverID, 0 );
// Set email subject
oSmtp->Subject = L"simple email from Visual C++ with gmail account";
oSmtp->BodyText = L"Hi :)";
//adds attachment from local disk
if(oSmtp->AddAttachment( L"images/imagename.bmp") != 0)
{
printf("Failed to add attachment with error: %s\r\n", (const TCHAR*)oSmtp->GetLastErrDescription());
}
// Gmail SMTP server address
oSmtp->ServerAddr = L"smtp.gmail.com";
// If you want to use direct SSL 465 port,
// Please add this line, otherwise TLS will be used.
// oSmtp->ServerPort = 465;
// detect SSL/TLS automatically
oSmtp->SSL_init();
// Gmail user authentication should use your
// Gmail email address as the user name.
oSmtp->UserName = L"mygmailid@gmail.com";
oSmtp->Password =L"passowrd123";
printf("Start to send email via gmail account ...\r\n" );
if( oSmtp->SendMail() == 0 )
{ printf("email was sent successfully!\r\n");
}
else
{ printf("failed to send email with the following error: %s\r\n",(const TCHAR*)oSmtp->GetLastErrDescription());
}
if( oSmtp != NULL )
oSmtp.Release();
return 0;
}
</code>
I want the control to be active so that I can continue with other processes while the sending the mail happens on the background.
Can anyone pls help me in this !!!
Thankx a ton in advance.....
Regards,
Sandhya.
I m trying to send a mail via c++ code. I downloaded EASendMail component installer in ma system.
Then using this i wrote a code in vc++. I m sending a mail using a gmail id.I m able to send the mail correctly.
The issue i m facing is that the code hangs for the time it takes to send the mail.when i get a notification tat the mail is sent , den the cursor becomes active.I send the receiver address to the function i m calling.
<code>
using namespace EASendMailObjLib;
using namespace std;
int SendMail(LPTSTR RecieverID)
{
::CoInitialize( NULL );
IMailPtr oSmtp = NULL;
oSmtp.CreateInstance( "EASendMailObj.Mail");
oSmtp->LicenseCode = L"TryIt";
// Set your gmail email address
oSmtp->FromAddr = L"mygmailid@gmail.com";
// Add recipient email address
oSmtp->AddRecipientEx( RecieverID, 0 );
// Set email subject
oSmtp->Subject = L"simple email from Visual C++ with gmail account";
oSmtp->BodyText = L"Hi :)";
//adds attachment from local disk
if(oSmtp->AddAttachment( L"images/imagename.bmp") != 0)
{
printf("Failed to add attachment with error: %s\r\n", (const TCHAR*)oSmtp->GetLastErrDescription());
}
// Gmail SMTP server address
oSmtp->ServerAddr = L"smtp.gmail.com";
// If you want to use direct SSL 465 port,
// Please add this line, otherwise TLS will be used.
// oSmtp->ServerPort = 465;
// detect SSL/TLS automatically
oSmtp->SSL_init();
// Gmail user authentication should use your
// Gmail email address as the user name.
oSmtp->UserName = L"mygmailid@gmail.com";
oSmtp->Password =L"passowrd123";
printf("Start to send email via gmail account ...\r\n" );
if( oSmtp->SendMail() == 0 )
{ printf("email was sent successfully!\r\n");
}
else
{ printf("failed to send email with the following error: %s\r\n",(const TCHAR*)oSmtp->GetLastErrDescription());
}
if( oSmtp != NULL )
oSmtp.Release();
return 0;
}
</code>
I want the control to be active so that I can continue with other processes while the sending the mail happens on the background.
Can anyone pls help me in this !!!
Thankx a ton in advance.....
Regards,
Sandhya.
↧
Trouble with GetDIBits()
Hello guys, I'm new to C++ and I couldn't figure out the proper way to store pixel data of a device context into an array using GetDIBits(). Currently I am trying to get the RGB values of a single pixel of a bitmap file:
gBit.bmp, the bitmap file selected into MemDC, is an entirely white 24-bit bitmap image, so I thought cout should display 255, but for some reason it displays some weird characters. Most probably p is not initialized since the same values are returned when I remove the line containing GetDIBits(). Am I using this function properly? What could I possibly be doing wrong here?
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main() {HDC MemDC=CreateCompatibleDC(NULL);
SelectObject(MemDC,(HBITMAP)LoadImage(NULL,(LPCTSTR)"F:\\gBit.bmp",IMAGE_BITMAP,1366,768,LR_LOADFROMFILE));
HBITMAP hBit=(HBITMAP)LoadImage(NULL,(LPCTSTR)"F:\\gBit.bmp",IMAGE_BITMAP,1366,768,LR_LOADFROMFILE);
BITMAPINFO bmi;
BYTE p[3];
bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth=1;
bmi.bmiHeader.biHeight=-1;
bmi.bmiHeader.biPlanes=1;
bmi.bmiHeader.biBitCount=24;
bmi.bmiHeader.biCompression=BI_RGB;
bmi.bmiHeader.biSizeImage=0;
bmi.bmiHeader.biXPelsPerMeter=0;
bmi.bmiHeader.biYPelsPerMeter=0;
bmi.bmiHeader.biClrUsed=0;
bmi.bmiHeader.biClrImportant=0;
GetDIBits(MemDC,hBit,0,0,p,&bmi,DIB_RGB_COLORS);
cout<<p[0]<<endl<<p[1]<<endl<<p[2];
ReleaseDC(NULL,MemDC); DeleteDC(MemDC);
DeleteObject(hBit); while (1) {}
}
↧
GetDIBits() returns wrong BGR values:
GetDIBits() was not passing the correct BGR values to a COLORREF array:
bitmap.bmp is an entirely blue (RGB(0,0,255)) 10x10 24-bit bitmap file. The first few lines of the output look like:
0
0
255
255
0
0
0
255
0
0
0
255
And it's not only the order of the values that changes; some color values are 0 when they shouldn't be. The last few COLORREF values are RGB(0,0,0). What could be the problem with the code?
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main() {int i; HBITMAP hBit; HDC bdc; BITMAPINFO bmpInfo; COLORREF pixel[100];
hBit=(HBITMAP)LoadImage(NULL,(LPCTSTR)"F:\\bitmap.bmp",IMAGE_BITMAP,10,10,LR_LOADFROMFILE);
bdc=CreateCompatibleDC(NULL);
SelectObject(bdc,hBit);
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFO);
bmpInfo.bmiHeader.biWidth=10;
bmpInfo.bmiHeader.biHeight=-10;
bmpInfo.bmiHeader.biPlanes=1;
bmpInfo.bmiHeader.biBitCount=24;
bmpInfo.bmiHeader.biCompression=BI_RGB;
bmpInfo.bmiHeader.biSizeImage=0;
GetDIBits(bdc,hBit,0,10,pixel,&bmpInfo,DIB_RGB_COLORS);
for (i=0; i<100; i++) {
cout<<GetBValue(pixel[i]);
cout<<GetGValue(pixel[i]);
cout<<GetRValue(pixel[i]);
cout<<endl;
}
ReleaseDC(NULL,bdc);
DeleteDC(bdc);
DeleteObject(hBit);
free(pixel);
while (1) {}
}
0
0
255
255
0
0
0
255
0
0
0
255
And it's not only the order of the values that changes; some color values are 0 when they shouldn't be. The last few COLORREF values are RGB(0,0,0). What could be the problem with the code?
↧
↧
Simple Handle question
When using GetStdHandle() function I can understand you need to make sure that you have a valid Handle to be able to write (output) and read (input) to the console. What I don't understand, is whether obtaining those handles would ever fail? MSDN tells me that I could get INVALID_HANDLE_VALUE or NULL. I have never received those values? Clearly if either write or read handles did produce an error my program should exit?
This brings me to the STD_ERROR_HANDLE. Is it really necessary to use this handle or even quit a program if this returned an error? This handle is not as important as the two I mentioned earlier?
I am new to this and just need a better understanding of these handles.
This brings me to the STD_ERROR_HANDLE. Is it really necessary to use this handle or even quit a program if this returned an error? This handle is not as important as the two I mentioned earlier?
I am new to this and just need a better understanding of these handles.
↧
Wm_drawitem
I'm writing a chessboard with GDI and when I click on a square the color changes to the opposite color but then it wont get redrawn again to normal.
I verified and I get only 5 WM_DRAWITEM message after I click a case instead of 64.
I wonder why?
I verified and I get only 5 WM_DRAWITEM message after I click a case instead of 64.
I wonder why?
Code:
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(linker, "/subsystem:\"console\" /entry:\"WinMainCRTStartup\"")
#define ID_SQUARE_1 101
#define ID_SQUARE_2 102
#define SIZE 80
bool BlackOrWhite = 0;
int j=1, k=1, Ycoord=SIZE;
HINSTANCE hInst ;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
void CheckClickedSquare(int wParam)
{
switch (wParam)
{
case ID_SQUARE_1:
//cout <<"1 work"<< endl;
break ;
case ID_SQUARE_2:
//cout << "2 work" << endl;
break ;
}
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("GDI Chessboard") ;
MSG msg ;
HWND hwnd ;
WNDCLASS wndclass ;
hInst = hInstance ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = szAppName ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, TEXT ("GDI Chessboard Demo"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
820, 800,
NULL, NULL, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND h[64];
static int cxClient, cyClient, cxChar, cyChar ;
int cx, cy ;
LPDRAWITEMSTRUCT pdis ;
POINT pt[3] ;
RECT rc ;
PAINTSTRUCT ps;
HDC hdc;
int x = 116,y=100, number=0;
char ch = 'A';
char str[2], num[2];
switch (message)
{
case WM_CREATE :
cout << "WM_CREATE" << endl;
cxChar = LOWORD (GetDialogBaseUnits ());
cyChar = HIWORD (GetDialogBaseUnits ());
for (int i=1; i<65; i++)
{
h[i] = CreateWindow (TEXT ("button"), TEXT (""),
WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
0, 0, SIZE, SIZE,
hwnd, (HMENU)(i+100), 0, NULL);
}
return 0 ;
case WM_SIZE :
cout << "WM_SIZE" << endl;
for (int i=1; i<65; i++)
{
if(i%8==1)
{
j=1;
Ycoord += SIZE;
}
MoveWindow (h[i], j*SIZE, Ycoord-90, SIZE, SIZE, TRUE);
j++;
}
return 0 ;
case WM_DRAWITEM :
cout << "WM_DRAWITEM" << endl;
pdis = (LPDRAWITEMSTRUCT) lParam ;
// Fill area with white and frame it black
if(k++%8==1)
{
BlackOrWhite = !BlackOrWhite;
}
if(BlackOrWhite)
{
FillRect (pdis->hDC, &pdis->rcItem,
(HBRUSH) GetStockObject (WHITE_BRUSH)) ;
}
else
{
FillRect (pdis->hDC, &pdis->rcItem,
(HBRUSH) GetStockObject (BLACK_BRUSH)) ;
}
BlackOrWhite = !BlackOrWhite;
FrameRect (pdis->hDC, &pdis->rcItem,
(HBRUSH) GetStockObject (BLACK_BRUSH)) ;
return 0 ;
case WM_PAINT:
cout << "WM_PAINT" << endl;
hdc = BeginPaint(hwnd, &ps);
for (int i=1; i<9; i++)
{
sprintf(str,"%c", ch++);
TextOut(hdc, x+((i-1)*(SIZE)), 40, str, 1);
sprintf(num,"%i", i);
TextOut(hdc, 60, y+((i-1)*(SIZE)), num, 1);
}
EndPaint(hwnd, &ps) ;
return 0;
case WM_COMMAND :
cout << wParam << endl;
CheckClickedSquare(wParam);
return 0 ;
case WM_DESTROY :
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
↧
[RESOLVED] Simple Handle question
When using GetStdHandle() function I can understand you need to make sure that you have a valid Handle to be able to write (output) and read (input) to the console. What I don't understand, is whether obtaining those handles would ever fail? MSDN tells me that I could get INVALID_HANDLE_VALUE or NULL. I have never received those values? Clearly if either write or read handles did produce an error my program should exit?
This brings me to the STD_ERROR_HANDLE. Is it really necessary to use this handle or even quit a program if this returned an error? This handle is not as important as the two I mentioned earlier?
I am new to this and just need a better understanding of these handles.
This brings me to the STD_ERROR_HANDLE. Is it really necessary to use this handle or even quit a program if this returned an error? This handle is not as important as the two I mentioned earlier?
I am new to this and just need a better understanding of these handles.
↧
[RESOLVED] Largest Console window supported?
I am having issues with establishing the largest console window supported on my system. I have written this code:
This reports X = 170 Y = 59 on my system. Issue here is that if I open a dos window (CMD), I am able to open the properties of that window and adjust the window size beyond what my method reports? How can I achieve this?
Code:
void vmApp::GetMaxConsoleAppSize()
{
COORD maxConsoleSize;
maxConsoleSize = GetLargestConsoleWindowSize(m_hStdOut);
cout << "X = " << maxConsoleSize.X << " Y = " << maxConsoleSize.Y << endl;
m_nMaxAppWidth = maxConsoleSize.X;
m_nMaxAppHeight = maxConsoleSize.Y;
}
↧
↧
COleVariant in WinAPI (afxdisp.h)
Hey ho...
guess i need some help of experts again.. wanna export listview to MS excel. i found a really nice article on this:
http://www.codeproject.com/Articles/...mation-Using-C
however the only one thing that does not seem to work with my OLE is COleVariant class.
It's simply not declared. I tried adding afxdisp.h but it's not a standard lib in my Microsoft Visual Visual Studio Express 2012 and it seems to be very specific to MFC.
I tried to add it manually from internet but it's then referring (calling) to other *.h
is there any way to either replace COleVariant with VARIANT (or something) or add afxdisp.h (and all connected libs) to my program?
i wanna achieve this :
will be grateful for any hint!
thanks
.
guess i need some help of experts again.. wanna export listview to MS excel. i found a really nice article on this:
http://www.codeproject.com/Articles/...mation-Using-C
however the only one thing that does not seem to work with my OLE is COleVariant class.
It's simply not declared. I tried adding afxdisp.h but it's not a standard lib in my Microsoft Visual Visual Studio Express 2012 and it seems to be very specific to MFC.
I tried to add it manually from internet but it's then referring (calling) to other *.h
is there any way to either replace COleVariant with VARIANT (or something) or add afxdisp.h (and all connected libs) to my program?
i wanna achieve this :
Code:
IDispatch* pRange;
{
COleVariant oleRange(szCell);
VARIANT result;
VariantInit(&result);
m_hr=OLEMethod(DISPATCH_PROPERTYGET, &result, pSheet, L"Range", 1, oleRange.Detach());
pRange = result.pdispVal;
}
thanks
.
↧
Win32 API vs MFC vs SDK
Hello everyone!
I'm learning win32 api and have a few questions which I can't find any easy answers to. It would be great if someone could explain them!
So what I've understood so far is that Win32 uses C, wherein I have to write my own code to deisgn the window, i.e. the old fashioned way.
And MFC are C++ classes, like a wrapper around Win32. It makes designing easier by the drag and drop functionality.
But what is SDK?
And is there a difference between MFC functions/objects and MFC CObject API?
My concepts are all over the place right now....so it would be really awesome if someone could help me understand.
Thanks a lot for the help!! I really appreciate it! :)
I'm learning win32 api and have a few questions which I can't find any easy answers to. It would be great if someone could explain them!
So what I've understood so far is that Win32 uses C, wherein I have to write my own code to deisgn the window, i.e. the old fashioned way.
And MFC are C++ classes, like a wrapper around Win32. It makes designing easier by the drag and drop functionality.
But what is SDK?
And is there a difference between MFC functions/objects and MFC CObject API?
My concepts are all over the place right now....so it would be really awesome if someone could help me understand.
Thanks a lot for the help!! I really appreciate it! :)
↧
Draw with OpenGL in edit control on the dialog box.
Hello everyone,
I have created a dialog box (WinAPI). I added a Edit Control upon it. I want to draw inside with it using OPenGL.
I simply set the color of the background of the edit control to red.
The problem is that sometimes when dialog appear the edit control is not colored. When i bring another window on top of the dialog box it becomes colored. Sometimes when program starts everything is fine.
Here is the message processing procedure:
Maybe i need to process some additional messages?
I have created a dialog box (WinAPI). I added a Edit Control upon it. I want to draw inside with it using OPenGL.
I simply set the color of the background of the edit control to red.
The problem is that sometimes when dialog appear the edit control is not colored. When i bring another window on top of the dialog box it becomes colored. Sometimes when program starts everything is fine.
Here is the message processing procedure:
Code:
WM_INITDIALIG:
dc1 = GetDC(GetDlgItem(handle,IDC_EDIT1));
gldc1 = SetDCFormat(dc1);
WM_PAINT:
wglMakeCurrent(dc1,gldc1);
GetClientRect(GetDlgItem(handle,IDC_EDIT1),&client_rect);
draw();
glFlush();
SwapBuffers(dc1);
↧
CreateFile not creating UNICODE file
Hey ho!
I wanna create an XML file which will be in UNICODE format, otherwise EXCEL won't read the local diacritic chars (e.g "ń", "ś", "ć" etc). The chars are in the file after generation but due to some reason EXCEL does not understand it as a compatible XML format. I always need to open the file in notepad manually and change the coding from ANSI to UNICODE (just save as UNICODE) and only then i can open it in EXCEL.
Is there any way of doing this already when the file is created in my program ?
I use this:
I tried CreateFileW as well as e.g. _T(filename) but the file is always generated as ANSI...
any idea?
would be grateful for any hint.
thankx
berkov
.
I wanna create an XML file which will be in UNICODE format, otherwise EXCEL won't read the local diacritic chars (e.g "ń", "ś", "ć" etc). The chars are in the file after generation but due to some reason EXCEL does not understand it as a compatible XML format. I always need to open the file in notepad manually and change the coding from ANSI to UNICODE (just save as UNICODE) and only then i can open it in EXCEL.
Is there any way of doing this already when the file is created in my program ?
I use this:
Code:
HANDLE plik = CreateFile( filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
any idea?
would be grateful for any hint.
thankx
berkov
.
↧
↧
Send to option - how to handle in program?
Hi there.
In windows' context menu there is an option "Send to.". I'd like to send a text file (or a few of them) by choosing this option and later my program.exe from the list. How can I handle the process of receiving those filenames within my C++ program in order to open those files afterwards using ifstream?
In windows' context menu there is an option "Send to.". I'd like to send a text file (or a few of them) by choosing this option and later my program.exe from the list. How can I handle the process of receiving those filenames within my C++ program in order to open those files afterwards using ifstream?
↧
::LoadLibrary not working on my Windows XP machine
I wrote a C++ program way back on Windows 95 with Visual C++ 4.0/6.0 compilers long ago.
I have now upgraded the old project .mdp files to Visual Studio 8.0's .sln files. That process went very smoothly as there is a converter built in to the compiler.
Now, on my Vista machine, the program runs fine. It's an executable and calls one other dll. No problem there.
But on the XP machine, a call I make to LoadLibrary((LPCWSTR) "MSVCRT.dll") fails with error code 126 (more or less this is file/path not found). Now there are about a dozen or so versions of that dll on my XP machine, in addition to the usual one in C:\WINDOWS\system32. Perhaps of the 12, 4 or 5 have different dates. Well anyway, I tried running ProcessMonitor, and I 've tried other stuff, but to no avail.
Does anyone have a huge, grand strategy that I can take to resolve this issue. My ultimate purpose is just to do this kind of thing (and this works fine on my Vista machine which also has Visual Studio 5.0/8.0, likewise my XP machine setup).
So ultimately, it's, provided I've gotten a nice m_hDll_ handle from the LoadLibrary call:
pFun = (pfMyFunc)::GetProcAddress(m_hDll_, "sin");
I just cannot get the LoadLibrary call to work on my XP machine. Any help appreciated.
Thank you.
WhatNow46
I have now upgraded the old project .mdp files to Visual Studio 8.0's .sln files. That process went very smoothly as there is a converter built in to the compiler.
Now, on my Vista machine, the program runs fine. It's an executable and calls one other dll. No problem there.
But on the XP machine, a call I make to LoadLibrary((LPCWSTR) "MSVCRT.dll") fails with error code 126 (more or less this is file/path not found). Now there are about a dozen or so versions of that dll on my XP machine, in addition to the usual one in C:\WINDOWS\system32. Perhaps of the 12, 4 or 5 have different dates. Well anyway, I tried running ProcessMonitor, and I 've tried other stuff, but to no avail.
Does anyone have a huge, grand strategy that I can take to resolve this issue. My ultimate purpose is just to do this kind of thing (and this works fine on my Vista machine which also has Visual Studio 5.0/8.0, likewise my XP machine setup).
So ultimately, it's, provided I've gotten a nice m_hDll_ handle from the LoadLibrary call:
pFun = (pfMyFunc)::GetProcAddress(m_hDll_, "sin");
I just cannot get the LoadLibrary call to work on my XP machine. Any help appreciated.
Thank you.
WhatNow46
↧
[RESOLVED] Cannot load bitmap resource onto button, but can do so if I load the filesystem file
So I'm trying to load a bitmap onto a button, which I can do if I get the bitmap handle like this:
LoadImage(NULL, _T("C:\\Users\\Luis\\Documents\\Visual Studio 2012\\Projects\\dlltest\\Debug\\status1.bmp"), IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
However, when I attempt to load this same image from a resource as follows it doesn't work:
LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS1), IMAGE_BITMAP, NULL, NULL, LR_CREATEDIBSECTION);
I had also tried LoadBitmap without success:
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_STATUS1));
None of these lines produces a NULL result, so they seem to succeed, but only the first will actually load a bitmap onto a button on my dialog:
SendMessage(hBtn1,BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);
Is it possible that either or both of these last two calls cannot locate the actual requested bitmap and so they returned a valid handle to like, a blank bitmap? Or would a NULL result failure be the only expected alternative to complete success? I do load the dialog from the same resource and it works just fine.
Having to load these bitmaps from external files makes deployment a little less friendly. Any clues what might be the problem?
LoadImage(NULL, _T("C:\\Users\\Luis\\Documents\\Visual Studio 2012\\Projects\\dlltest\\Debug\\status1.bmp"), IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
However, when I attempt to load this same image from a resource as follows it doesn't work:
LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS1), IMAGE_BITMAP, NULL, NULL, LR_CREATEDIBSECTION);
I had also tried LoadBitmap without success:
LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_STATUS1));
None of these lines produces a NULL result, so they seem to succeed, but only the first will actually load a bitmap onto a button on my dialog:
SendMessage(hBtn1,BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);
Is it possible that either or both of these last two calls cannot locate the actual requested bitmap and so they returned a valid handle to like, a blank bitmap? Or would a NULL result failure be the only expected alternative to complete success? I do load the dialog from the same resource and it works just fine.
Having to load these bitmaps from external files makes deployment a little less friendly. Any clues what might be the problem?
↧
COleVariant in WinAPI (afxdisp.h)
Hey ho...
guess i need some help of experts again.. wanna export listview to MS excel. i found a really nice article on this:
http://www.codeproject.com/Articles/...mation-Using-C
however the only one thing that does not seem to work with my OLE is COleVariant class.
It's simply not declared. I tried adding afxdisp.h but it's not a standard lib in my Microsoft Visual Visual Studio Express 2012 and it seems to be very specific to MFC.
I tried to add it manually from internet but it's then referring (calling) to other *.h
is there any way to either replace COleVariant with VARIANT (or something) or add afxdisp.h (and all connected libs) to my program?
i wanna achieve this :
will be grateful for any hint!
thanks
.
guess i need some help of experts again.. wanna export listview to MS excel. i found a really nice article on this:
http://www.codeproject.com/Articles/...mation-Using-C
however the only one thing that does not seem to work with my OLE is COleVariant class.
It's simply not declared. I tried adding afxdisp.h but it's not a standard lib in my Microsoft Visual Visual Studio Express 2012 and it seems to be very specific to MFC.
I tried to add it manually from internet but it's then referring (calling) to other *.h
is there any way to either replace COleVariant with VARIANT (or something) or add afxdisp.h (and all connected libs) to my program?
i wanna achieve this :
Code:
IDispatch* pRange;
{
COleVariant oleRange(szCell);
VARIANT result;
VariantInit(&result);
m_hr=OLEMethod(DISPATCH_PROPERTYGET, &result, pSheet, L"Range", 1, oleRange.Detach());
pRange = result.pdispVal;
}
thanks
.
↧
↧
Draw with OpenGL in edit control on the dialog box.
Hello everyone,
I have created a dialog box (WinAPI). I added a Edit Control upon it. I want to draw inside with it using OPenGL.
I simply set the color of the background of the edit control to red.
The problem is that sometimes when dialog appear the edit control is not colored. When i bring another window on top of the dialog box it becomes colored. Sometimes when program starts everything is fine.
Here is the message processing procedure:
Maybe i need to process some additional messages?
I have created a dialog box (WinAPI). I added a Edit Control upon it. I want to draw inside with it using OPenGL.
I simply set the color of the background of the edit control to red.
The problem is that sometimes when dialog appear the edit control is not colored. When i bring another window on top of the dialog box it becomes colored. Sometimes when program starts everything is fine.
Here is the message processing procedure:
Code:
WM_INITDIALIG:
dc1 = GetDC(GetDlgItem(handle,IDC_EDIT1));
gldc1 = SetDCFormat(dc1);
WM_PAINT:
wglMakeCurrent(dc1,gldc1);
GetClientRect(GetDlgItem(handle,IDC_EDIT1),&client_rect);
draw();
glFlush();
SwapBuffers(dc1);
↧
Access (click) buttons in other apps' widnows? (MinGW g++)
I would like to make a simple application that clicks some buttons in other (already open) applications' windows. I also would like to avoid VC and use MinGW g++ instead. Is it possible? If so could someone point me to the references/tutorials/examples? Thanks!
↧
MultiThread Race Condition
MultiThread Race Condition
I have read a lot about abstract class, but still have questions, as I have not really used in my c++ code practically.
What is the use of abstract class ? Any sample I can take a look at ?
Thanks.
I have read a lot about abstract class, but still have questions, as I have not really used in my c++ code practically.
What is the use of abstract class ? Any sample I can take a look at ?
Thanks.
↧