在做IMAPI的東西的時候,需要用到CoCOM的東西,
然後他又需要使用ATL....總之很麻煩0rz
好了,重點就是在trace bug的時候跑到atlcom.h這個檔案裡面的
class CComObjectCached : public Base
{
public:
typedef Base _BaseClass;
CComObjectCached(void* = NULL){}
// Set refcount to -(LONG_MAX/2) to protect destruction and
// also catch mismatched Release in debug builds
// This will be made virtual again for Beta 2
/*virtual*/ ~CComObjectCached()
{
m_dwRef = -(LONG_MAX/2);
FinalRelease();
#ifdef _ATL_DEBUG_INTERFACES
_AtlDebugInterfacesModule.DeleteNonAddRefThunk(_GetRawUnknown());
#endif
}
//If InternalAddRef or InternalRelease is undefined then your class
//doesn't derive from CComObjectRoot
STDMETHOD_(ULONG, AddRef)() throw()
{
ULONG l = InternalAddRef();
if (l == 2)
_pAtlModule->Lock();
return l;
}
沒錯,就是_pAtlModule->Lock();這邊,然後你發現他記憶體位址居然是0x000000
然後就crash了!
不要相信甚麼add ATL support to MFC 之類的鬼話(加了以後我不知道怎麼刪掉,只能重寫)
解決方法:
在你的主程式(.cpp)裡面,
#include .......
//在這邊新增
CComModule _Module;
extern __declspec(selectany) CAtlModule* _pAtlModule=&_Module;
//新增完成
主程式:建構子....
主程式.....
這樣就可以解決了
END
2016年4月22日 星期五
2016年3月9日 星期三
[C++] Visual C++ 2005 遇到的問題- fatal error LNK 1103 解決方法
遇到這個問題,網路上也是有很多解法,
其實不外乎就是VC 2005有bug ,所以需要補釘(hotfix)
但是問題是hotfix在microsoft官網已經掛點了
所以你需要
https://mega.nz/#!V5VhgDyR!F4MKmJzRFi0_vVLofU7qYImIjSy42AXVOPh09DVDisQ
這個補釘
如果還是不夠還需要另一個"VS80sp1-KB926603-X86-CHT"這個檔案,但這個檔案網路上可以找到,就不提供了
END
其實不外乎就是VC 2005有bug ,所以需要補釘(hotfix)
但是問題是hotfix在microsoft官網已經掛點了
所以你需要
https://mega.nz/#!V5VhgDyR!F4MKmJzRFi0_vVLofU7qYImIjSy42AXVOPh09DVDisQ
這個補釘
如果還是不夠還需要另一個"VS80sp1-KB926603-X86-CHT"這個檔案,但這個檔案網路上可以找到,就不提供了
END
2015年7月9日 星期四
[iOS] 特效進度條(ASProgressPopupView)的使用方法
在Code4app網站中找到一個不錯的特效包--ASProgressPopupView
點此連結到Code4app
上面寫的很簡單,但實際使用起來卻不是這樣
"使用方法:
self.progressView.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:26];
self.progressView.popUpViewAnimatedColors = @[[UIColor redColor], [UIColor orangeColor], [UIColor greenColor]];
self.progressView.popUpViewCornerRadius = 16.0;"
實際在github上的描述是:
github
然後如果要調整他的弧度的話(邊角弧度)
點此連結到Code4app
上面寫的很簡單,但實際使用起來卻不是這樣
"使用方法:
self.progressView.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:26];
self.progressView.popUpViewAnimatedColors = @[[UIColor redColor], [UIColor orangeColor], [UIColor greenColor]];
self.progressView.popUpViewCornerRadius = 16.0;"
實際在github上的描述是:
github
How to use it
It’s very simple. Drag a UIProgressView into your Storyboard/nib and set its class to ASProgressPopUpView – that's it. The example below demonstrates how to customize the appearance.
self.progressView.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:26];
self.progressView.popUpViewAnimatedColors = @[[UIColor redColor], [UIColor orangeColor], [UIColor greenColor]];
self.progressView.popUpViewCornerRadius = 16.0;
To show the popUpView, just call:
[self.progressView showPopUpViewAnimated:YES];
And to hide:
[self.progressView hidePopUpViewAnimated:YES];
You update the value exactly as you would normally use a UIProgressView, just update the
progress
property self.progressView.progress = 0.31;
詳細的可以去github上面看
這邊的教學:
1.先把下面這四個檔案copy進去專案,然後在你要寫的.m file裡面新增
#import "ASValueTrackingSlider.h"
2.開啟你的xib file,拉一個slider進去畫面,把class改為ASValueTrackingSlider
然後把該元件拉到.m file產生一個名叫slider1的物件
可以看到他的屬性是ASValueTrackingSlider,不是uislider,是的話就搞錯囉!
接著我們就可以使用slider1來做事情(控制他)
3.為了讓我的進度條上面顯示的文字最後面都有個"V",所以這邊要增加三行(第一行是宣告)
NSNumberFormatter *voltFormatter = [[NSNumberFormatter alloc] init];
[voltFormatter setPositiveSuffix:@"V"];
[voltFormatter setNegativeSuffix:@"V"];
再來就是一些基本的設定
self.slider1.popUpViewCornerRadius = 12.0;
[self.slider1 setNumberFormatter:voltFormatter];
[self.slider1 setMaxFractionDigitsDisplayed:0];
self.slider1.popUpViewColor = [UIColor colorWithHue:0.55 saturation:0.8 brightness:0.9 alpha:0.7];
self.slider1.font = [UIFont fontWithName:@"GillSans-Bold" size:22];
self.slider1.popUpViewAnimatedColors = @[[UIColor redColor], [UIColor orangeColor], [UIColor greenColor]];
//這邊是讓我前中後段的顏色有不同
[self.slider1 showPopUpViewAnimated:YES];
//這一段一定要show不然他不會顯示文字出來
如果是要有%數的話則改用這段
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterPercentStyle];
[self.slider1 setNumberFormatter:formatter];
self.slider1.popUpViewAnimatedColors = @[[UIColor greenColor], [UIColor orangeColor], [UIColor redColor]];
self.slider1.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:26];
[self.slider1 showPopUpViewAnimated:YES];
又或者你想要到某個區段就顯示某些文字的話,請加入這一行
self.slider1.dataSource = self;
然後加入這一段
- (NSString *)slider:(ASValueTrackingSlider *)slider stringForValue:(float)value;
{
value = roundf(value);
NSString *s;
if (value < 30) {
s = @"Warning!! Low Voltage";
} else if (value > 29.0 && value < 50.0) {
s = [NSString stringWithFormat:@"😎 %@ 😎", [slider.numberFormatter stringFromNumber:@(value)]];
} else if (value >= 50.0) {
s = [NSString stringWithFormat:@"%dV", value];
}
return s;
}
最後,完成版本就像這樣~
然後如果要調整他的弧度的話(邊角弧度)
self.slider2.popUpViewCornerRadius = 12.0;
這邊可以調整
這邊可以調整
希望大家都能夠開心使用,(畢竟作者沒有講很清楚,我也摸了一會兒才會),end
2015年1月22日 星期四
[Android] "ClassNotFoundException" / " Binary XML file line # : Error inflating class” / " multiple dex files define"錯誤解決
在寫Android的時候會使用到別人所用的library,
常常會看到ClassNotFound or Binary XML line #數字 Error inflating class
他的意思就是說(如果我沒有會錯意的話) :他找不到你import的那個library
為什麼呢?
可能性有幾種(我目前知道解決方式也只有兩種,所以就列出兩種)
1) 你沒有正確import Library
請確定這裡面有打勾了,而不是紅色的X (如果沒有正確import就remove掉重新import一次)
通常新建的專案都會有內建android-support-v4.jar 但是你library又有一份,所以就class not found
exception ,因為她不知道要用哪一個(應該是這樣吧?)
這個就簡單一點,把lib資料夾裡面的android-support-v4.jar 刪除就可以了!
當然會造成classnotfoundexception 跟 error inflating class可能原因有很多,只列舉我找到的解決
方式,紀錄一下 End
補充: multiple dex files define 也是有可能有重複的android-support-v4.jar(刪除即可)
常常會看到ClassNotFound or Binary XML line #數字 Error inflating class
他的意思就是說(如果我沒有會錯意的話) :他找不到你import的那個library
為什麼呢?
可能性有幾種(我目前知道解決方式也只有兩種,所以就列出兩種)
1) 你沒有正確import Library
請確定這裡面有打勾了,而不是紅色的X (如果沒有正確import就remove掉重新import一次)
通常新建的專案都會有內建android-support-v4.jar 但是你library又有一份,所以就class not found
exception ,因為她不知道要用哪一個(應該是這樣吧?)
這個就簡單一點,把lib資料夾裡面的android-support-v4.jar 刪除就可以了!
當然會造成classnotfoundexception 跟 error inflating class可能原因有很多,只列舉我找到的解決
方式,紀錄一下 End
補充: multiple dex files define 也是有可能有重複的android-support-v4.jar(刪除即可)
訂閱:
文章 (Atom)