|
thanx for reply;
"SaveAs" is a member function of "Kodak Image Edit Control" class. it Saves the displayed image using the file name specified.
when i complile and link the code it does not give any error.
But when i click "save" button for which i wrote the code it says that "Illegal Function Call Invalid file type specified". and nothing happens on closing error message box
bye
chan
|
|
|
|
|
OK thats a little bit clearer. Have you tried to step through the code and find out where it failes?
Looking at your code I would check the following:
What data should the m_edit variable save? (BTW you should not use the m_ prefix unless the variable is a member variable of a class or if you want to confuse other readers of your class ). Does the m_edit variable contain this data? Your code implies that a new CImgEdit variable is created and not intitialized with any data. Am I correct?
If your SaveAs function is calling some Win32 function internally and is passing the VARIANTs to that function you should use VARIANT_TRUE instead of the C++ "true" constant. I would also recommend using wrapper classes for the variant data type, _variant_t, COleVariant and CComVariant are possible alternatives. This would simplify coding a bit since these classes handle necessary memory management internally. In this case that won't matter too much since you're mosly using int and bool but generally this is safer. Your code would look like this:
_variant_t vtSaveAtZoom( VARIANT_TRUE );
_variant_t vtCompression( 1024 );
_variant_t vtCompressionType( 6 );
_variant_t vtPageType( 2 );
_variant_t vtFileType( 6 );
and the _variant_t wrapper takes care of setting the vt member variable to the appropriate value. BTW what do these constants (1024, 6, 2 and 6) mean?
Hope this helps.
Daniel
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
thanx for reply ; i will try this
actually i am using a activex control "Kodak Image Edit Control" . so i created m_edit veriable.
the function has following arguments in VB
object.SaveAs Image[,FileType,PageType,CompressionType,CompressionInfo,SaveAtZoom]
Arguments
Parameter Data Type
Image String
FileType Integer(enumerated)
PageType Integer(enumerated)
CompressionType Integer(enumerated)
CompressionInfo Integer(enumerated)
SaveAtZoom Boolean
and in VC++
SaveAs(LPCTSTR Image, const VARIANT& FileType, const VARIANT& PageType, const VARIANT& CompressionType, const VARIANT& CompressionInfo, const VARIANT& SaveAtZoom)
this function Saves the displayed image using the file name specified. (1024, 6, 2 and 6) these indicate some image properties so i am using it.
really Thanx a lot for ur reply.
bye
|
|
|
|
|
In that case I think your problem stems from the fact that you are creating a new variable. Where is the picture you want to save? Is it visible on the screen? If so I suppose you already have a control somewhere that contains the image you want to save and you need to ask that control to save itself instead of creating a new (empty) instance and ask it to save itself.
What I would do if I were you:
- locate the control that displays the image you want to save. Use that instead of this new instance (m_edit).
- Instead of using 1024, 6 and 2 directly I would use an enumeration. The function signature suggests that this enumeration already exists - check if you can find it. This will not make the code work but it will be more readable (I for instance have no idea what 6 represents as CompressionInfo but a named enumeration constant would definitely give me a better hint about what the constants represents).
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
If I have a button on dialog box and I want to write program to open blank window when I click that button. Do you know how to do that?
|
|
|
|
|
It depends on wether you're using Win32 or MFC
If it is Win32 then you can just call the "CreateWindow" function or "DialogParam" (or related DialogBox functions) to popup a dialog from the resource.
If you're using MFC create a CWnd or CDialog object and call it's 'Create' or 'DoModal' function.
It's as simple as that...
Hope this helps you a bit.
RicoH
Don't think you are, know you are...
|
|
|
|
|
Does anyone know how to insert the EventViewer MMC Snap-in into an MFC application?
Thanks in advance,
Dragos
|
|
|
|
|
In VC++ 6.0 you can find an item "user defined keywords" in the 'Tools - Options - Format' menu.
I'm just woundering if this means you can supply your own list of keywords which the IDE should recognize...
If so, I would really like to know how to define this list.
Thankz...
Don't think you are, know you are...
|
|
|
|
|
I just cut and pasted from a page in MSDN:
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001OCT\1033\vcug.chm::/html/_asug_set_syntax_coloring.htm[^]
To set syntax coloring for user-defined keywords
In the same directory as msdev.exe, use the Text editor or Windows Notepad to create a text-only file named usertype.dat.
Add your keywords to usertype.dat, one keyword per line.
Note The usertype.dat file is read during initialization. It cannot be renamed, nor can it be reloaded during an editing session. The syntax coloring mechanism checks the usertype.dat file last. Thus, all previously defined color settings take precedence over the user-defined keywords.
Save the file as a text-only file, exit, and then restart Visual Studio.
From the Tools menu, choose Options.
Select the Format tab.
In the Colors box, select User Defined Keywords.
Set the font, font size, foreground color, and background color to your preferences.
For more information, see To change colors used in syntax coloring.
Click OK.
=====================================
I hope that helped,
Iain.
|
|
|
|
|
Aah... works like a charm
Thankz
Don't think you are, know you are...
|
|
|
|
|
I have derived a class from CButton and I have
overridden OnPaint and OnDraw methods in order
to change the control appearance.
This class work without problems if the custom
control is placed in a CDialog window.
When I place my control in a CDialogBar window,
my class does't work: OnPaint is never called.
I have also used the Invalidate method for the
CDialogBar window and for the custom control but
the WM_PAINT message doesn't reach my control.
How can I solve this problem ??
I have also tried to call the OnPaint method of
the CDialogBar window through its parent window
and I have had another problem. The fllowing code
fails when I try to create a CPaintDC object:
void CGradHistogram::OnPaint()
{
CRect rectUpdate;
CBitmap* pOldBitmap;
CPaintDC dc(this); <<<<<<<---- FAILS HERE
CRect l_crctGraphic;
if(!m_boDcInitialized)
{
GetClientRect(&l_crctGraphic);
// Creates the memory device context and the bitmap
if(m_pdcMemory->GetSafeHdc() == NULL)
{
CClientDC ClientDc(this);
m_pdcMemory->CreateCompatibleDC(&ClientDc);
m_pBitmap->CreateCompatibleBitmap(&ClientDc, l_crctGraphic.Width(),
l_crctGraphic.Height());
m_pdcMemory->SetMapMode(MM_TEXT);
}
else
{
AfxMessageBox(_T("Cannot create DC!!!"), MB_OK | MB_ICONEXCLAMATION);
}
m_boDcInitialized = TRUE;
}
dc.GetClipBox(&rectUpdate);
pOldBitmap = m_pdcMemory->SelectObject(m_pBitmap);
m_pdcMemory->SelectClipRgn(NULL);
m_pdcMemory->IntersectClipRect(&rectUpdate);
OnDraw(m_pdcMemory);
dc.BitBlt(rectUpdate.left, rectUpdate.top,
rectUpdate.Width(), rectUpdate.Height(),
m_pdcMemory, rectUpdate.left, rectUpdate.top,
SRCCOPY);
m_pdcMemory->SelectObject(pOldBitmap);
}
Does someone can help me ???
Thanks a lot !!!!
|
|
|
|
|
what's the equivalent of load icon for text file?
i have an array of character strings in text files.
name1@myserv.com
name2@myserv.com
name3@myserv.com
name4@myserv.com
name5@myserv.com
name6@myserv.com
...
...
I wish to include the file as application resources for my MFC dialog app. During construction of the dialog class, i want to load this file, line by line and put the email address into a character array.
For icons:
HICON hListIcon[6];
hListIcon[0] = AfxGetApp()->LoadIcon(IDI_ICON1);
hListIcon[1] = AfxGetApp()->LoadIcon(IDI_ICON2);
hListIcon[2] = AfxGetApp()->LoadIcon(IDI_ICON3);
hListIcon[3] = AfxGetApp()->LoadIcon(IDI_ICON4);
hListIcon[4] = AfxGetApp()->LoadIcon(IDI_ICON5);
hListIcon[5] = AfxGetApp()->LoadIcon(IDI_ICON6);
Can I do something similar for text file?
Thanks
norm
|
|
|
|
|
Not sure I understand. Two things:
a) if you wish your text strings not to be part of a text file but part of your application's resource: use LoadString().
b) if you wish your text strings to be part of a normal text file: honestly, seek advise in any book about C programming, C++ programming, MFC, etc etc. This is a very basic issue that is covered everywhere.
|
|
|
|
|
a) if you wish your text strings not to be part of a text file but part of your application's resource: use LoadString().
thanks, but entering 10k entries into the string table manually?
b) if you wish your text strings to be part of a normal text file: honestly, seek advise in any book about C programming, C++ programming, MFC, etc etc. This is a very basic issue that is covered everywhere.
yea man, that's not what i'm asking neither. but nevermind.
norm
|
|
|
|
|
Hi, everyone!
We are beginning a project, and we want to use VSS
to manage source codes.
I am a beginner of VSS. So I want to know where can I
find some step by step guides on VSS?
Cheers,
Georhe
|
|
|
|
|
I would think the User's Guide is the best place to look.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks, Bhavnani pal!
Where can I find the User's Guide as
you mentioned?
Cheers,
George
|
|
|
|
|
It came with my retail copy of VSS. A brief overview of the product is available here[^].
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks, Bhavnani pal!
I have read the article you mentioned. I think it
just contains general information of VSS and does
not teach me how to use the software.
I want to get some guides that teach me how to use
VSS step by step.
Can you help?
Cheers,
George
|
|
|
|
|
I know the ip address of a host and i want to know the name of that host. For this purpose i am using following code:
<code>struct hostent *hp;
unsigned int addr = inet_addr(m_strHost);
hp = gethostbyaddr((char *)&addr,4,AF_INET);
if (hp == NULL )
{
printf("\n Failed: %d",WSAGetLastError());
}
else
{
printf( "%s\n\n", hp->h_name );
}</code>
It is working fine for my LAN that uses ip address of type 192.x.x.x. But the problem occurs when i give the ip address of host over internet. As such sometimes gethostbyaddr is successful and in most cases it fails. It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Strange that it is happening in office and not at home. Any idea ??? Or any other alternative way to determine host name when ip address is known ???
Strange that it is not failing in all cases. For example, the ipaddress of yahoo.com is: 64.58.79.230. If i give this ip address then, the program runs successful and the hostname returned as: w1.rc.vip.dcx.yahoo.com
But if i give the ip address: 207.219.70.31 (which is that of codeproject.com), then i get error 11004, and gethostbyaddr returns NULL
|
|
|
|
|
Shamoon wrote:
hp = gethostbyaddr((char *)&addr,4,AF_INET);
Hm... better to make a sizeof(addr) instead of putting 4 there...
Shamoon wrote:
It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Hm... in my book 11004 is:
11004—WSANO_DATA
No data record of the requested type found. This error is also associated with gethostbyname and gethostbyaddr. It indicates that the supplied name was valid but that no data record of the requested type was found with it.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi,
I am developing ATL EXE server (multithreaded) which contains std::map that i used to store the data of type structure. This std::map will be accessed by clients (ASP web application) via interfaces provided by the ATL EXE server:
struct ScheduledDevice<br />
{<br />
CComBSTR RefID;<br />
CComBSTR Name;<br />
DATE StartTime;<br />
DATE EndTime;<br />
int Status;<br />
long Command;<br />
};<br />
<br />
typedef map<BSTR, ScheduledDevice> SCHEDULELIST;<br />
SCHEDULELIST m_Schedule;<br />
<br />
HRESULT CMonitorDeviceThread::Add(BSTR DeviceName, DATE StartTime, DATE EndsTime, BSTR RefID)<br />
{<br />
ScheduledDevice obj;<br />
<br />
obj.Name = DeviceName;<br />
obj.StartTime = StartTime;<br />
obj.EndTime = EndsTime;<br />
obj.RefID = RefID;<br />
obj.Status = bookOpenStatus;<br />
<br />
EnterCriticalSection(&cs); <br />
m_Schedule[obj.RefID] = obj;<br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}<br />
<br />
HRESULT CMonitorDeviceThread::Cancel(BSTR RefID)<br />
{ <br />
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs); <br />
if( ( m_Iterator = m_Schedule.find( RefID ) ) != m_Schedule.end() ) {<br />
<br />
if ( (*m_Iterator).second.Status == bookExecuteStatus )<br />
return E_FAIL;
<br />
m_Schedule.erase( m_Iterator ); <br />
<br />
} else<br />
return E_INVALIDARG;
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}
At different ATL EXE server thread I will continuosly read and modify the std::map (every 2 seconds).
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs);<br />
<br />
for ( m_Iterator = m_Schedule.begin(); m_Iterator != m_Schedule.end(); m_Iterator++ )<br />
{ <br />
<br />
SYSTEMTIME dtStartTime, dtEndTime, stCurDate;<br />
<br />
VariantTimeToSystemTime( (*m_Iterator).second.StartTime, &dtStartTime );<br />
VariantTimeToSystemTime( (*m_Iterator).second.EndTime, &dtEndTime );<br />
GetLocalTime(&stCurDate);<br />
<br />
CHighTime bookStartTime( dtStartTime ); <br />
CHighTime bookEndTime( dtEndTime ); <br />
CHighTime curTime( stCurDate ); <br />
<br />
CHighTimeSpan sDiffStartTime = bookStartTime - curTime;<br />
CHighTimeSpan sDiffEndTime = bookEndTime - curTime;<br />
<br />
long diffStart = sDiffStartTime.GetTotalMinutes(); <br />
long diffEnd = sDiffEndTime.GetTotalMinutes(); <br />
<br />
if ( ( diffStart == 0 || ( diffStart >= -5 && diffStart <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookOpenStatus ) {<br />
<br />
(*m_Iterator).second.Status = bookExecuteStatus;<br />
<br />
}<br />
<br />
<br />
if ( ( diffEnd == 0 || ( diffEnd >= -10 && diffEnd <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookExecuteStatus ) {<br />
<br />
<big>m_Schedule.erase( m_Iterator );</big> <br />
<br />
}<br />
<br />
<br />
}
<br />
LeaveCriticalSection(&cs);
But somehow when I run the application (server and clients) the ATL EXE server just crash! I think the problem occured at std::map.erase method.
I dont how to replace this statement since I need to check all items in std::map to do the validation (get the StartTime/EndTime and compare it with current time).
For info, I've add the std::map item using BSTR unique key (ex: 124568798314). This key represent data in my database application.
Thank u very very much in advance . Any advice, help and suggestions strongly aprreciated.
Regards,
newbie
|
|
|
|
|
once you call erase, the iterator becomes invalid.
erase will return an iterator to the next item.
so your loop looks something like this
for (it=stuff.begin();it!=stuff.end();)
{
bool bKeepThisOne=SomeCondition(it);
if (bKeepThisOne)
++it;
else
it=stuff.erase(it);
}
|
|
|
|
|
I am trying to connect to an SQL server database using the OLE DB templates but am getting above error when linking. The code causing the error is:
hr = m_srcProduct.OpenWithServiceComponents(CLSID_SQLOLEDB, &initStd, 1);
//(m_srcProduct is a CDataSource object)
I have sqloledb.h included in stdafx.h, it has the declaration for CLSID_SQLOLEDB but it is declared extern which I think may be the problem....
//----------------------------------------------------------------------------
// Provider-specific Class Ids
#ifdef DBINITCONSTANTS
// Provider CLSID {0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}
extern const GUID CLSID_SQLOLEDB ={0xc7ff16cL,0x38e3,0x11d0,{0x97,0xab,0x0,0xc0,0x4f,0xc2,0xad,0x98}};
how to fix?
|
|
|
|
|
I have an SDI application with multiple views available. Each view is derived from CFormView and is specified with a unique dialog ID.
My question is how do I change the view from one view to a user select one? I have options off of the menu bar that the user selects, this puts all the view changes inside my CMainFrm class. I don't want to destroy the original view that the application starts with, but after that all of the new views can be destroyed after they are used and moved to a new one.
Any help is appreciated.
-Eric
|
|
|
|
|